Refactored duplicated test code to a setup.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2932 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
548d5a21f6
commit
945ea9b01c
|
@ -291,65 +291,49 @@ class ProjectTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
context "#copy" do
|
context "#copy" do
|
||||||
|
setup do
|
||||||
|
ProjectCustomField.destroy_all # Custom values are a mess to isolate in tests
|
||||||
|
Project.destroy_all :identifier => "copy-test"
|
||||||
|
@source_project = Project.find(2)
|
||||||
|
@project = Project.new(:name => 'Copy Test', :identifier => 'copy-test')
|
||||||
|
@project.trackers = @source_project.trackers
|
||||||
|
@project.enabled_modules = @source_project.enabled_modules
|
||||||
|
end
|
||||||
|
|
||||||
should "copy issues" do
|
should "copy issues" do
|
||||||
# Setup
|
assert @project.valid?
|
||||||
ProjectCustomField.destroy_all # Custom values are a mess to isolate in tests
|
assert @project.issues.empty?
|
||||||
source_project = Project.find(2)
|
assert @project.copy(@source_project)
|
||||||
Project.destroy_all :identifier => "copy-test"
|
|
||||||
project = Project.new(:name => 'Copy Test', :identifier => 'copy-test')
|
|
||||||
project.trackers = source_project.trackers
|
|
||||||
assert project.valid?
|
|
||||||
|
|
||||||
assert project.issues.empty?
|
assert_equal @source_project.issues.size, @project.issues.size
|
||||||
assert project.copy(source_project)
|
@project.issues.each do |issue|
|
||||||
|
|
||||||
# Tests
|
|
||||||
assert_equal source_project.issues.size, project.issues.size
|
|
||||||
project.issues.each do |issue|
|
|
||||||
assert issue.valid?
|
assert issue.valid?
|
||||||
assert ! issue.assigned_to.blank?
|
assert ! issue.assigned_to.blank?
|
||||||
assert_equal project, issue.project
|
assert_equal @project, issue.project
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
should "copy members" do
|
should "copy members" do
|
||||||
# Setup
|
assert @project.valid?
|
||||||
ProjectCustomField.destroy_all # Custom values are a mess to isolate in tests
|
assert @project.members.empty?
|
||||||
source_project = Project.find(2)
|
assert @project.copy(@source_project)
|
||||||
project = Project.new(:name => 'Copy Test', :identifier => 'copy-test')
|
|
||||||
project.trackers = source_project.trackers
|
|
||||||
project.enabled_modules = source_project.enabled_modules
|
|
||||||
assert project.valid?
|
|
||||||
|
|
||||||
assert project.members.empty?
|
assert_equal @source_project.members.size, @project.members.size
|
||||||
assert project.copy(source_project)
|
@project.members.each do |member|
|
||||||
|
|
||||||
# Tests
|
|
||||||
assert_equal source_project.members.size, project.members.size
|
|
||||||
project.members.each do |member|
|
|
||||||
assert member
|
assert member
|
||||||
assert_equal project, member.project
|
assert_equal @project, member.project
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
should "copy project specific queries" do
|
should "copy project specific queries" do
|
||||||
# Setup
|
assert @project.valid?
|
||||||
ProjectCustomField.destroy_all # Custom values are a mess to isolate in tests
|
assert @project.queries.empty?
|
||||||
source_project = Project.find(2)
|
assert @project.copy(@source_project)
|
||||||
project = Project.new(:name => 'Copy Test', :identifier => 'copy-test')
|
|
||||||
project.trackers = source_project.trackers
|
|
||||||
project.enabled_modules = source_project.enabled_modules
|
|
||||||
assert project.valid?
|
|
||||||
|
|
||||||
assert project.queries.empty?
|
assert_equal @source_project.queries.size, @project.queries.size
|
||||||
assert project.copy(source_project)
|
@project.queries.each do |query|
|
||||||
|
|
||||||
# Tests
|
|
||||||
assert_equal source_project.queries.size, project.queries.size
|
|
||||||
project.queries.each do |query|
|
|
||||||
assert query
|
assert query
|
||||||
assert_equal project, query.project
|
assert_equal @project, query.project
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue