Removing shoulda context.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11315 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2013-02-03 09:20:05 +00:00
parent de8033d183
commit 14b50dfbab
7 changed files with 412 additions and 524 deletions

View File

@ -198,8 +198,7 @@ class AttachmentTest < ActiveSupport::TestCase
assert a.readable?
end
context "Attachmnet.attach_files" do
should "attach the file" do
test "Attachmnet.attach_files should attach the file" do
issue = Issue.first
assert_difference 'Attachment.count' do
Attachment.attach_files(issue,
@ -219,7 +218,7 @@ class AttachmentTest < ActiveSupport::TestCase
assert_equal 59, File.size(attachment.diskfile)
end
should "add unsaved files to the object as unsaved attachments" do
test "Attachmnet.attach_files should add unsaved files to the object as unsaved attachments" do
# Max size of 0 to force Attachment creation failures
with_settings(:attachment_max_size => 0) do
@project = Project.find(1)
@ -235,7 +234,6 @@ class AttachmentTest < ActiveSupport::TestCase
assert_equal response[:unsaved], @project.unsaved_attachments
end
end
end
def test_latest_attach
set_fixtures_attachments_directory

View File

@ -58,61 +58,48 @@ class AuthSourceLdapTest < ActiveSupport::TestCase
end
if ldap_configured?
context '#authenticate' do
setup do
@auth = AuthSourceLdap.find(1)
@auth.update_attribute :onthefly_register, true
end
test '#authenticate with a valid LDAP user should return the user attributes' do
auth = AuthSourceLdap.find(1)
auth.update_attribute :onthefly_register, true
context 'with a valid LDAP user' do
should 'return the user attributes' do
attributes = @auth.authenticate('example1','123456')
attributes = auth.authenticate('example1','123456')
assert attributes.is_a?(Hash), "An hash was not returned"
assert_equal 'Example', attributes[:firstname]
assert_equal 'One', attributes[:lastname]
assert_equal 'example1@redmine.org', attributes[:mail]
assert_equal @auth.id, attributes[:auth_source_id]
assert_equal auth.id, attributes[:auth_source_id]
attributes.keys.each do |attribute|
assert User.new.respond_to?("#{attribute}="), "Unexpected :#{attribute} attribute returned"
end
end
test '#authenticate with an invalid LDAP user should return nil' do
auth = AuthSourceLdap.find(1)
assert_equal nil, auth.authenticate('nouser','123456')
end
context 'with an invalid LDAP user' do
should 'return nil' do
assert_equal nil, @auth.authenticate('nouser','123456')
end
test '#authenticate without a login should return nil' do
auth = AuthSourceLdap.find(1)
assert_equal nil, auth.authenticate('','123456')
end
context 'without a login' do
should 'return nil' do
assert_equal nil, @auth.authenticate('','123456')
end
test '#authenticate without a password should return nil' do
auth = AuthSourceLdap.find(1)
assert_equal nil, auth.authenticate('edavis','')
end
context 'without a password' do
should 'return nil' do
assert_equal nil, @auth.authenticate('edavis','')
end
test '#authenticate without filter should return any user' do
auth = AuthSourceLdap.find(1)
assert auth.authenticate('example1','123456')
assert auth.authenticate('edavis', '123456')
end
context 'without filter' do
should 'return any user' do
assert @auth.authenticate('example1','123456')
assert @auth.authenticate('edavis', '123456')
end
end
test '#authenticate with filter should return user who matches the filter only' do
auth = AuthSourceLdap.find(1)
auth.filter = "(mail=*@redmine.org)"
context 'with filter' do
setup do
@auth.filter = "(mail=*@redmine.org)"
end
should 'return user who matches the filter only' do
assert @auth.authenticate('example1','123456')
assert_nil @auth.authenticate('edavis', '123456')
end
end
assert auth.authenticate('example1','123456')
assert_nil auth.authenticate('edavis', '123456')
end
def test_authenticate_should_timeout

View File

@ -1129,49 +1129,44 @@ class IssueTest < ActiveSupport::TestCase
assert_nil copy.custom_value_for(2)
end
context "#copy" do
setup do
@issue = Issue.find(1)
end
should "not create a journal" do
copy = @issue.copy(:project_id => 3, :tracker_id => 2, :assigned_to_id => 3)
test "#copy should not create a journal" do
copy = Issue.find(1).copy(:project_id => 3, :tracker_id => 2, :assigned_to_id => 3)
copy.save!
assert_equal 0, copy.reload.journals.size
end
should "allow assigned_to changes" do
copy = @issue.copy(:project_id => 3, :tracker_id => 2, :assigned_to_id => 3)
test "#copy should allow assigned_to changes" do
copy = Issue.find(1).copy(:project_id => 3, :tracker_id => 2, :assigned_to_id => 3)
assert_equal 3, copy.assigned_to_id
end
should "allow status changes" do
copy = @issue.copy(:project_id => 3, :tracker_id => 2, :status_id => 2)
test "#copy should allow status changes" do
copy = Issue.find(1).copy(:project_id => 3, :tracker_id => 2, :status_id => 2)
assert_equal 2, copy.status_id
end
should "allow start date changes" do
test "#copy should allow start date changes" do
date = Date.today
copy = @issue.copy(:project_id => 3, :tracker_id => 2, :start_date => date)
copy = Issue.find(1).copy(:project_id => 3, :tracker_id => 2, :start_date => date)
assert_equal date, copy.start_date
end
should "allow due date changes" do
test "#copy should allow due date changes" do
date = Date.today
copy = @issue.copy(:project_id => 3, :tracker_id => 2, :due_date => date)
copy = Issue.find(1).copy(:project_id => 3, :tracker_id => 2, :due_date => date)
assert_equal date, copy.due_date
end
should "set current user as author" do
test "#copy should set current user as author" do
User.current = User.find(9)
copy = @issue.copy(:project_id => 3, :tracker_id => 2)
copy = Issue.find(1).copy(:project_id => 3, :tracker_id => 2)
assert_equal User.current, copy.author
end
should "create a journal with notes" do
test "#copy should create a journal with notes" do
date = Date.today
notes = "Notes added when copying"
copy = @issue.copy(:project_id => 3, :tracker_id => 2, :start_date => date)
copy = Issue.find(1).copy(:project_id => 3, :tracker_id => 2, :start_date => date)
copy.init_journal(User.current, notes)
copy.save!
@ -1180,7 +1175,6 @@ class IssueTest < ActiveSupport::TestCase
assert_equal 0, journal.details.size
assert_equal notes, journal.notes
end
end
def test_valid_parent_project
issue = Issue.find(1)
@ -1454,51 +1448,48 @@ class IssueTest < ActiveSupport::TestCase
).overdue?
end
context "#behind_schedule?" do
should "be false if the issue has no start_date" do
test "#behind_schedule? should be false if the issue has no start_date" do
assert !Issue.new(:start_date => nil,
:due_date => 1.day.from_now.to_date,
:done_ratio => 0).behind_schedule?
end
should "be false if the issue has no end_date" do
test "#behind_schedule? should be false if the issue has no end_date" do
assert !Issue.new(:start_date => 1.day.from_now.to_date,
:due_date => nil,
:done_ratio => 0).behind_schedule?
end
should "be false if the issue has more done than it's calendar time" do
test "#behind_schedule? should be false if the issue has more done than it's calendar time" do
assert !Issue.new(:start_date => 50.days.ago.to_date,
:due_date => 50.days.from_now.to_date,
:done_ratio => 90).behind_schedule?
end
should "be true if the issue hasn't been started at all" do
test "#behind_schedule? should be true if the issue hasn't been started at all" do
assert Issue.new(:start_date => 1.day.ago.to_date,
:due_date => 1.day.from_now.to_date,
:done_ratio => 0).behind_schedule?
end
should "be true if the issue has used more calendar time than it's done ratio" do
test "#behind_schedule? should be true if the issue has used more calendar time than it's done ratio" do
assert Issue.new(:start_date => 100.days.ago.to_date,
:due_date => Date.today,
:done_ratio => 90).behind_schedule?
end
end
context "#assignable_users" do
should "be Users" do
test "#assignable_users should be Users" do
assert_kind_of User, Issue.find(1).assignable_users.first
end
should "include the issue author" do
test "#assignable_users should include the issue author" do
non_project_member = User.generate!
issue = Issue.generate!(:author => non_project_member)
assert issue.assignable_users.include?(non_project_member)
end
should "include the current assignee" do
test "#assignable_users should include the current assignee" do
user = User.generate!
issue = Issue.generate!(:assigned_to => user)
user.lock!
@ -1506,7 +1497,7 @@ class IssueTest < ActiveSupport::TestCase
assert Issue.find(issue.id).assignable_users.include?(user)
end
should "not show the issue author twice" do
test "#assignable_users should not show the issue author twice" do
assignable_user_ids = Issue.find(1).assignable_users.collect(&:id)
assert_equal 2, assignable_user_ids.length
@ -1516,8 +1507,7 @@ class IssueTest < ActiveSupport::TestCase
end
end
context "with issue_group_assignment" do
should "include groups" do
test "#assignable_users with issue_group_assignment should include groups" do
issue = Issue.new(:project => Project.find(2))
with_settings :issue_group_assignment => '1' do
@ -1525,10 +1515,8 @@ class IssueTest < ActiveSupport::TestCase
assert issue.assignable_users.include?(Group.find(11))
end
end
end
context "without issue_group_assignment" do
should "not include groups" do
test "#assignable_users without issue_group_assignment should not include groups" do
issue = Issue.new(:project => Project.find(2))
with_settings :issue_group_assignment => '0' do
@ -1536,8 +1524,6 @@ class IssueTest < ActiveSupport::TestCase
assert !issue.assignable_users.include?(Group.find(11))
end
end
end
end
def test_create_should_send_email_notification
ActionMailer::Base.deliveries.clear
@ -1728,73 +1714,42 @@ class IssueTest < ActiveSupport::TestCase
assert_equal [2, 3, 8], Issue.find(1).all_dependent_issues.collect(&:id).sort
end
context "#done_ratio" do
setup do
test "#done_ratio should use the issue_status according to Setting.issue_done_ratio" do
@issue = Issue.find(1)
@issue_status = IssueStatus.find(1)
@issue_status.update_attribute(:default_done_ratio, 50)
@issue2 = Issue.find(2)
@issue_status2 = IssueStatus.find(2)
@issue_status2.update_attribute(:default_done_ratio, 0)
end
teardown do
Setting.issue_done_ratio = 'issue_field'
end
context "with Setting.issue_done_ratio using the issue_field" do
setup do
Setting.issue_done_ratio = 'issue_field'
end
should "read the issue's field" do
with_settings :issue_done_ratio => 'issue_field' do
assert_equal 0, @issue.done_ratio
assert_equal 30, @issue2.done_ratio
end
end
context "with Setting.issue_done_ratio using the issue_status" do
setup do
Setting.issue_done_ratio = 'issue_status'
end
should "read the Issue Status's default done ratio" do
with_settings :issue_done_ratio => 'issue_status' do
assert_equal 50, @issue.done_ratio
assert_equal 0, @issue2.done_ratio
end
end
end
context "#update_done_ratio_from_issue_status" do
setup do
test "#update_done_ratio_from_issue_status should update done_ratio according to Setting.issue_done_ratio" do
@issue = Issue.find(1)
@issue_status = IssueStatus.find(1)
@issue_status.update_attribute(:default_done_ratio, 50)
@issue2 = Issue.find(2)
@issue_status2 = IssueStatus.find(2)
@issue_status2.update_attribute(:default_done_ratio, 0)
end
context "with Setting.issue_done_ratio using the issue_field" do
setup do
Setting.issue_done_ratio = 'issue_field'
end
should "not change the issue" do
with_settings :issue_done_ratio => 'issue_field' do
@issue.update_done_ratio_from_issue_status
@issue2.update_done_ratio_from_issue_status
assert_equal 0, @issue.read_attribute(:done_ratio)
assert_equal 30, @issue2.read_attribute(:done_ratio)
end
end
context "with Setting.issue_done_ratio using the issue_status" do
setup do
Setting.issue_done_ratio = 'issue_status'
end
should "change the issue's done ratio" do
with_settings :issue_done_ratio => 'issue_status' do
@issue.update_done_ratio_from_issue_status
@issue2.update_done_ratio_from_issue_status
@ -1802,7 +1757,6 @@ class IssueTest < ActiveSupport::TestCase
assert_equal 0, @issue2.read_attribute(:done_ratio)
end
end
end
test "#by_tracker" do
User.current = User.anonymous
@ -1873,48 +1827,42 @@ class IssueTest < ActiveSupport::TestCase
assert_equal before, Issue.on_active_project.length
end
context "Issue#recipients" do
setup do
@project = Project.find(1)
@author = User.generate!
@assignee = User.generate!
@issue = Issue.generate!(:project => @project, :assigned_to => @assignee, :author => @author)
end
should "include project recipients" do
assert @project.recipients.present?
@project.recipients.each do |project_recipient|
assert @issue.recipients.include?(project_recipient)
test "Issue#recipients should include project recipients" do
issue = Issue.generate!
assert issue.project.recipients.present?
issue.project.recipients.each do |project_recipient|
assert issue.recipients.include?(project_recipient)
end
end
should "include the author if the author is active" do
assert @issue.author, "No author set for Issue"
assert @issue.recipients.include?(@issue.author.mail)
test "Issue#recipients should include the author if the author is active" do
issue = Issue.generate!(:author => User.generate!)
assert issue.author, "No author set for Issue"
assert issue.recipients.include?(issue.author.mail)
end
should "include the assigned to user if the assigned to user is active" do
assert @issue.assigned_to, "No assigned_to set for Issue"
assert @issue.recipients.include?(@issue.assigned_to.mail)
test "Issue#recipients should include the assigned to user if the assigned to user is active" do
issue = Issue.generate!(:assigned_to => User.generate!)
assert issue.assigned_to, "No assigned_to set for Issue"
assert issue.recipients.include?(issue.assigned_to.mail)
end
should "not include users who opt out of all email" do
@author.update_attribute(:mail_notification, :none)
assert !@issue.recipients.include?(@issue.author.mail)
test "Issue#recipients should not include users who opt out of all email" do
issue = Issue.generate!(:author => User.generate!)
issue.author.update_attribute(:mail_notification, :none)
assert !issue.recipients.include?(issue.author.mail)
end
should "not include the issue author if they are only notified of assigned issues" do
@author.update_attribute(:mail_notification, :only_assigned)
assert !@issue.recipients.include?(@issue.author.mail)
test "Issue#recipients should not include the issue author if they are only notified of assigned issues" do
issue = Issue.generate!(:author => User.generate!)
issue.author.update_attribute(:mail_notification, :only_assigned)
assert !issue.recipients.include?(issue.author.mail)
end
should "not include the assigned user if they are only notified of owned issues" do
@assignee.update_attribute(:mail_notification, :only_owner)
assert !@issue.recipients.include?(@issue.assigned_to.mail)
end
test "Issue#recipients should not include the assigned user if they are only notified of owned issues" do
issue = Issue.generate!(:assigned_to => User.generate!)
issue.assigned_to.update_attribute(:mail_notification, :only_owner)
assert !issue.recipients.include?(issue.assigned_to.mail)
end
def test_last_journal_id_with_journals_should_return_the_journal_id

View File

@ -646,13 +646,8 @@ class MailHandlerTest < ActiveSupport::TestCase
assert_equal 'This is a html-only email.', issue.description
end
context "truncate emails based on the Setting" do
context "with no setting" do
setup do
Setting.mail_handler_body_delimiters = ''
end
should "add the entire email into the issue" do
test "truncate emails with no setting should add the entire email into the issue" do
with_settings :mail_handler_body_delimiters => '' do
issue = submit_email('ticket_on_given_project.eml')
assert_issue_created(issue)
assert issue.description.include?('---')
@ -660,11 +655,8 @@ class MailHandlerTest < ActiveSupport::TestCase
end
end
context "with a single string" do
setup do
Setting.mail_handler_body_delimiters = '---'
end
should "truncate the email at the delimiter for the issue" do
test "truncate emails with a single string should truncate the email at the delimiter for the issue" do
with_settings :mail_handler_body_delimiters => '---' do
issue = submit_email('ticket_on_given_project.eml')
assert_issue_created(issue)
assert issue.description.include?('This paragraph is before delimiters')
@ -674,11 +666,8 @@ class MailHandlerTest < ActiveSupport::TestCase
end
end
context "with a single quoted reply (e.g. reply to a Redmine email notification)" do
setup do
Setting.mail_handler_body_delimiters = '--- Reply above. Do not remove this line. ---'
end
should "truncate the email at the delimiter with the quoted reply symbols (>)" do
test "truncate emails with a single quoted reply should truncate the email at the delimiter with the quoted reply symbols (>)" do
with_settings :mail_handler_body_delimiters => '--- Reply above. Do not remove this line. ---' do
journal = submit_email('issue_update_with_quoted_reply_above.eml')
assert journal.is_a?(Journal)
assert journal.notes.include?('An update to the issue by the sender.')
@ -687,11 +676,8 @@ class MailHandlerTest < ActiveSupport::TestCase
end
end
context "with multiple quoted replies (e.g. reply to a reply of a Redmine email notification)" do
setup do
Setting.mail_handler_body_delimiters = '--- Reply above. Do not remove this line. ---'
end
should "truncate the email at the delimiter with the quoted reply symbols (>)" do
test "truncate emails with multiple quoted replies should truncate the email at the delimiter with the quoted reply symbols (>)" do
with_settings :mail_handler_body_delimiters => '--- Reply above. Do not remove this line. ---' do
journal = submit_email('issue_update_with_multiple_quoted_reply_above.eml')
assert journal.is_a?(Journal)
assert journal.notes.include?('An update to the issue by the sender.')
@ -700,11 +686,8 @@ class MailHandlerTest < ActiveSupport::TestCase
end
end
context "with multiple strings" do
setup do
Setting.mail_handler_body_delimiters = "---\nBREAK"
end
should "truncate the email at the first delimiter found (BREAK)" do
test "truncate emails with multiple strings should truncate the email at the first delimiter found (BREAK)" do
with_settings :mail_handler_body_delimiters => "---\nBREAK" do
issue = submit_email('ticket_on_given_project.eml')
assert_issue_created(issue)
assert issue.description.include?('This paragraph is before delimiters')
@ -714,7 +697,6 @@ class MailHandlerTest < ActiveSupport::TestCase
assert !issue.description.include?('This paragraph is after the delimiter')
end
end
end
def test_email_with_long_subject_line
issue = submit_email('ticket_with_long_subject.eml')

View File

@ -279,25 +279,21 @@ class MailerTest < ActiveSupport::TestCase
end
end
context("#issue_add") do
setup do
ActionMailer::Base.deliveries.clear
Setting.bcc_recipients = '1'
@issue = Issue.find(1)
end
should "notify project members" do
assert Mailer.issue_add(@issue).deliver
test "#issue_add should notify project members" do
issue = Issue.find(1)
assert Mailer.issue_add(issue).deliver
assert last_email.bcc.include?('dlopper@somenet.foo')
end
should "not notify project members that are not allow to view the issue" do
test "#issue_add should not notify project members that are not allow to view the issue" do
issue = Issue.find(1)
Role.find(2).remove_permission!(:view_issues)
assert Mailer.issue_add(@issue).deliver
assert Mailer.issue_add(issue).deliver
assert !last_email.bcc.include?('dlopper@somenet.foo')
end
should "notify issue watchers" do
test "#issue_add should notify issue watchers" do
issue = Issue.find(1)
user = User.find(9)
# minimal email notification options
user.pref[:no_self_notified] = '1'
@ -305,19 +301,19 @@ class MailerTest < ActiveSupport::TestCase
user.mail_notification = false
user.save
Watcher.create!(:watchable => @issue, :user => user)
assert Mailer.issue_add(@issue).deliver
Watcher.create!(:watchable => issue, :user => user)
assert Mailer.issue_add(issue).deliver
assert last_email.bcc.include?(user.mail)
end
should "not notify watchers not allowed to view the issue" do
test "#issue_add should not notify watchers not allowed to view the issue" do
issue = Issue.find(1)
user = User.find(9)
Watcher.create!(:watchable => @issue, :user => user)
Watcher.create!(:watchable => issue, :user => user)
Role.non_member.remove_permission!(:view_issues)
assert Mailer.issue_add(@issue).deliver
assert Mailer.issue_add(issue).deliver
assert !last_email.bcc.include?(user.mail)
end
end
# test mailer methods for each language
def test_issue_add

View File

@ -63,64 +63,46 @@ class PrincipalTest < ActiveSupport::TestCase
assert_equal expected_order.map(&:name).map(&:downcase), scope.sorted.all.map(&:name).map(&:downcase)
end
context "#like" do
setup do
Principal.create!(:login => 'login')
Principal.create!(:login => 'login2')
test "like scope should search login" do
results = Principal.like('jsmi')
Principal.create!(:firstname => 'firstname')
Principal.create!(:firstname => 'firstname2')
Principal.create!(:lastname => 'lastname')
Principal.create!(:lastname => 'lastname2')
Principal.create!(:mail => 'mail@example.com')
Principal.create!(:mail => 'mail2@example.com')
@palmer = Principal.create!(:firstname => 'David', :lastname => 'Palmer')
assert results.any?
assert results.all? {|u| u.login.match(/jsmi/i) }
end
should "search login" do
results = Principal.like('login')
test "like scope should search firstname" do
results = Principal.like('john')
assert_equal 2, results.count
assert results.all? {|u| u.login.match(/login/) }
assert results.any?
assert results.all? {|u| u.firstname.match(/john/i) }
end
should "search firstname" do
results = Principal.like('firstname')
test "like scope should search lastname" do
results = Principal.like('smi')
assert_equal 2, results.count
assert results.all? {|u| u.firstname.match(/firstname/) }
assert results.any?
assert results.all? {|u| u.lastname.match(/smi/i) }
end
should "search lastname" do
results = Principal.like('lastname')
test "like scope should search mail" do
results = Principal.like('somenet')
assert_equal 2, results.count
assert results.all? {|u| u.lastname.match(/lastname/) }
assert results.any?
assert results.all? {|u| u.mail.match(/somenet/i) }
end
should "search mail" do
results = Principal.like('mail')
assert_equal 2, results.count
assert results.all? {|u| u.mail.match(/mail/) }
end
should "search firstname and lastname" do
results = Principal.like('david palm')
test "like scope should search firstname and lastname" do
results = Principal.like('john smi')
assert_equal 1, results.count
assert_equal @palmer, results.first
assert_equal User.find(2), results.first
end
should "search lastname and firstname" do
results = Principal.like('palmer davi')
test "like scope should search lastname and firstname" do
results = Principal.like('smith joh')
assert_equal 1, results.count
assert_equal @palmer, results.first
end
assert_equal User.find(2), results.first
end
def test_like_scope_with_cyrillic_name

View File

@ -435,56 +435,54 @@ class ProjectTest < ActiveSupport::TestCase
assert_equal [1,2], parent.rolled_up_trackers.collect(&:id)
end
context "#rolled_up_versions" do
setup do
@project = Project.generate!
@parent_version_1 = Version.generate!(:project => @project)
@parent_version_2 = Version.generate!(:project => @project)
test "#rolled_up_versions should include the versions for the current project" do
project = Project.generate!
parent_version_1 = Version.generate!(:project => project)
parent_version_2 = Version.generate!(:project => project)
assert_same_elements [parent_version_1, parent_version_2], project.rolled_up_versions
end
should "include the versions for the current project" do
assert_same_elements [@parent_version_1, @parent_version_2], @project.rolled_up_versions
end
should "include versions for a subproject" do
@subproject = Project.generate!
@subproject.set_parent!(@project)
@subproject_version = Version.generate!(:project => @subproject)
test "#rolled_up_versions should include versions for a subproject" do
project = Project.generate!
parent_version_1 = Version.generate!(:project => project)
parent_version_2 = Version.generate!(:project => project)
subproject = Project.generate_with_parent!(project)
subproject_version = Version.generate!(:project => subproject)
assert_same_elements [
@parent_version_1,
@parent_version_2,
@subproject_version
], @project.rolled_up_versions
parent_version_1,
parent_version_2,
subproject_version
], project.rolled_up_versions
end
should "include versions for a sub-subproject" do
@subproject = Project.generate!
@subproject.set_parent!(@project)
@sub_subproject = Project.generate!
@sub_subproject.set_parent!(@subproject)
@sub_subproject_version = Version.generate!(:project => @sub_subproject)
@project.reload
test "#rolled_up_versions should include versions for a sub-subproject" do
project = Project.generate!
parent_version_1 = Version.generate!(:project => project)
parent_version_2 = Version.generate!(:project => project)
subproject = Project.generate_with_parent!(project)
sub_subproject = Project.generate_with_parent!(subproject)
sub_subproject_version = Version.generate!(:project => sub_subproject)
project.reload
assert_same_elements [
@parent_version_1,
@parent_version_2,
@sub_subproject_version
], @project.rolled_up_versions
parent_version_1,
parent_version_2,
sub_subproject_version
], project.rolled_up_versions
end
should "only check active projects" do
@subproject = Project.generate!
@subproject.set_parent!(@project)
@subproject_version = Version.generate!(:project => @subproject)
assert @subproject.archive
test "#rolled_up_versions should only check active projects" do
project = Project.generate!
parent_version_1 = Version.generate!(:project => project)
parent_version_2 = Version.generate!(:project => project)
subproject = Project.generate_with_parent!(project)
subproject_version = Version.generate!(:project => subproject)
assert subproject.archive
project.reload
@project.reload
assert !@subproject.active?
assert_same_elements [@parent_version_1, @parent_version_2], @project.rolled_up_versions
end
assert !subproject.active?
assert_same_elements [parent_version_1, parent_version_2], project.rolled_up_versions
end
def test_shared_versions_none_sharing
@ -611,12 +609,8 @@ class ProjectTest < ActiveSupport::TestCase
end
end
context "enabled_modules" do
setup do
test "enabled_modules should define module by names and preserve ids" do
@project = Project.find(1)
end
should "define module by names and preserve ids" do
# Remove one module
modules = @project.enabled_modules.slice(0..-2)
assert modules.any?
@ -628,7 +622,8 @@ class ProjectTest < ActiveSupport::TestCase
assert_equal @project.enabled_module_ids.sort, modules.collect(&:id).sort
end
should "enable a module" do
test "enabled_modules should enable a module" do
@project = Project.find(1)
@project.enabled_module_names = []
@project.reload
assert_equal [], @project.enabled_module_names
@ -643,7 +638,8 @@ class ProjectTest < ActiveSupport::TestCase
assert_equal ["issue_tracking", "gantt"], @project.enabled_module_names
end
should "disable a module" do
test "enabled_modules should disable a module" do
@project = Project.find(1)
#with string
assert @project.enabled_module_names.include?("issue_tracking")
@project.disable_module!("issue_tracking")
@ -657,7 +653,6 @@ class ProjectTest < ActiveSupport::TestCase
@project.disable_module!(first_module)
assert ! @project.reload.enabled_module_names.include?(first_module.name)
end
end
def test_enabled_module_names_should_not_recreate_enabled_modules
project = Project.find(1)