slimmer cucumber features, more specs instead

pull/495/head
jwollert 11 years ago
parent e2d863171b
commit f65b83b7f9
  1. 218
      features/projects/copy_project.feature
  2. 184
      spec/models/project/copy_spec.rb

@ -84,164 +84,6 @@ Feature: Project Settings
Then the "Identifier" field should not contain "project1" within "#content"
And the "Name" field should not contain "project1" within "#content"
@javascript
Scenario: Copy a project with some queries
When I am already admin
And the project "project1" has 10 work package queries with the following:
| is_public | true |
When I go to the settings page of the project "project1"
And I follow "Copy" within "#content"
And I fill in "Name" with "Copied Project"
And I fill in "Identifier" with "cp"
And I click on "Copy"
Then I should see "Successful creation."
When I go to the work package index page for the project "Copied Project"
Then I should see "Query 1" within "#sidebar"
Then I should see "Query 2" within "#sidebar"
Then I should see "Query 3" within "#sidebar"
Then I should see "Query 4" within "#sidebar"
Then I should see "Query 5" within "#sidebar"
Then I should see "Query 6" within "#sidebar"
Then I should see "Query 7" within "#sidebar"
Then I should see "Query 8" within "#sidebar"
Then I should see "Query 9" within "#sidebar"
Then I should see "Query 10" within "#sidebar"
@javascript
Scenario: Copy a project with some members (Users)
When I am already admin
And I go to the settings page of the project "project1"
And I follow "Copy" within "#content"
And I fill in "Name" with "Copied Project"
And I click on "Copy"
Then I should see "Successful creation."
When I go to the members tab of the settings page of the project "copied-project"
Then I should see the principal "Alice Alison" as a member with the roles:
| alpha |
And I should see the principal "Bob Bobbit" as a member with the roles:
| beta |
@javascript
Scenario: Copy a project with some members (Groups)
Given there is 1 group with the following:
| name | group1 |
And there is 1 group with the following:
| name | group2 |
And the group "group1" is a "alpha" in the project "project1"
And the group "group2" is a "alpha" in the project "project1"
When I am already admin
And I go to the settings page of the project "project1"
And I follow "Copy" within "#content"
And I fill in "Name" with "Copied Project"
And I click on "Copy"
Then I should see "Successful creation."
When I go to the members tab of the settings page of the project "copied-project"
Then I should see the principal "group1" as a member with the roles:
| alpha |
Then I should see the principal "group2" as a member with the roles:
| alpha |
@javascript
Scenario: Copy a project with some boards
When I am already admin
And there is a board "Board 1" for project "project1"
And there is a board "Board 2" for project "project1"
When I go to the settings page of the project "project1"
And I follow "Copy" within "#content"
And I fill in "Name" with "Copied Project"
And I fill in "Identifier" with "cp"
And I check "Forums"
And I click on "Copy"
Then I should see "Successful creation."
And I go to the overview page for the project "Copied Project"
And I follow "Forums" within "#main-menu"
Then I should see "Board 1" within "#content"
Then I should see "Board 2" within "#content"
@javascript
Scenario: Copy a project with project_a_associations
Given there are the following projects of type "Copy Project":
| project2 |
And there are the following project associations:
| Project A | Project B |
| project1 | project2 |
When I am already admin
And I go to the settings page of the project "project1"
And I follow "Copy" within "#content"
And I fill in "Name" with "Copied Project"
And I fill in "Identifier" with "cp"
And I check "Dependencies"
And I click on "Copy"
Then I should see "Successful creation."
And I go to the overview page for the project "Copied Project"
And I toggle the "Timelines" submenu
And I follow "Dependencies"
Then I should see "project2" within "#content"
@javascript
Scenario: Copy a project with project_b_associations
Given there are the following projects of type "Copy Project":
| project2 |
And there are the following project associations:
| Project A | Project B |
| project2 | project1 |
When I am already admin
And I go to the settings page of the project "project1"
And I follow "Copy" within "#content"
And I fill in "Name" with "Copied Project"
And I fill in "Identifier" with "cp"
And I check "Dependencies"
And I click on "Copy"
Then I should see "Successful creation."
And I go to the overview page for the project "Copied Project"
And I toggle the "Timelines" submenu
And I follow "Dependencies"
Then I should see "project2" within "#content"
@javascript
Scenario: Copy a project with versions
Given the project "project1" has 1 version with:
| name | version1 |
| description | yeah, boy |
| start_date | 2001-08-02 |
| effective_date | 2002-08-02 |
| status | closed |
When I am already admin
And I go to the settings page of the project "project1"
And I follow "Copy" within "#content"
And I fill in "Name" with "Copied Project"
And I fill in "Identifier" with "cp"
And I check "Versions"
And I click on "Copy"
Then I should see "Successful creation."
And I go to the versions tab of the settings page for the project "cp"
Then I should see "version1" within "#content"
And I should see "yeah, boy" within "#content"
And I should see "08/02/2001" within "#content"
And I should see "08/02/2002" within "#content"
And I should see "closed" within "#content"
@javascript
Scenario: Copy a project with categories
Given there is 1 user with the following:
| login | carl |
| firstname | Carl |
| Lastname | Carlson |
And the user "carl" is a "alpha" in the project "project1"
And the project "project1" has 2 categories with:
| assigned_to | Carl |
When I am already admin
And I go to the settings page of the project "project1"
And I follow "Copy" within "#content"
And I fill in "Name" with "Copied Project"
And I fill in "Identifier" with "cp"
And I check "Work package categories"
And I click on "Copy"
Then I should see "Successful creation."
And I go to the categories tab of the settings page for the project "cp"
Then I should see "Issue category 1" within "#content"
And I should see "Issue category 2" within "#content"
@javascript
Scenario: Copy a project with parent
Given there are the following projects of type "Copy Project":
@ -293,52 +135,6 @@ Feature: Project Settings
And I go to the settings page of the project "cp"
Then the "cfBug" checkbox should be checked
@javascript
Scenario: Copying a non-public project
Given I am already admin
And I go to the settings page of the project "project1"
And I uncheck "Public" within "#content"
And I press "Save" within "#content"
And I follow "Copy" within "#content"
And I fill in "Name" with "Copied Project"
And I fill in "Identifier" with "cp"
And I click on "Copy"
Then I should see "Successful creation."
And I go to the settings page of the project "cp"
Then the "Public" checkbox should not be checked within "#content"
@javascript
Scenario: Copying a public project
Given I am already admin
And I go to the settings page of the project "project1"
And I check "Public" within "#content"
And I press "Save" within "#content"
And I follow "Copy" within "#content"
And I fill in "Name" with "Copied Project"
And I fill in "Identifier" with "cp"
And I click on "Copy"
Then I should see "Successful creation."
And I go to the settings page of the project "cp"
Then the "Public" checkbox should be checked within "#content"
@javascript
Scenario: Copying a project with a wiki
Given the wiki page "Projektwiki" of the project "project1" has the following contents:
| yeah boy! |
And I am already admin
And I go to the settings page of the project "project1"
And I follow "Copy" within "#content"
And I fill in "Name" with "Copied Project"
And I fill in "Identifier" with "cp"
And I click on "Copy"
Then I should see "Successful creation."
And I go to the overview page for the project "Copied Project"
And I toggle the "Wiki" submenu
And I follow "Table of Contents" within "#main-menu"
Then I should see "Projektwiki" within "#content"
And I follow "Projektwiki" within "#content"
Then I should see "yeah boy!" within "#content"
@javascript
Scenario: Copying a project with some issues
Given the project "project1" has 1 issue with the following:
@ -378,20 +174,6 @@ Feature: Project Settings
And I go to the page of the planning element "pe2" of the project called "Copied Project"
Then I should see "pe2" within "#content"
@javascript
Scenario: Copying a project with a timeline
Given there is a timeline "Testline" for project "project1"
When I am already admin
And I go to the settings page of the project "project1"
And I follow "Copy" within "#content"
And I fill in "Name" with "Copied Project"
And I fill in "Identifier" with "cp"
And I check "Timeline reports"
And I click on "Copy"
Then I should see "Successful creation."
And I go to the page of the timeline "Testline" of the project called "Copied Project"
Then I should see "Testline" within "#content"
@javascript
Scenario: Copying a project with a complex issue
Given the project "project1" has 1 version with:

@ -42,20 +42,14 @@ describe Project::Copy do
subject { copy }
it "should be able to be copied" do
copy.should be_valid
copy.should_not be_new_record
end
end
describe :copy_attributes do
let(:project) do
project = FactoryGirl.create(:project_with_types)
work_package_custom_field = FactoryGirl.create(:work_package_custom_field)
project.work_package_custom_fields << work_package_custom_field
project.save
project
end
let(:project) { FactoryGirl.create(:project_with_types) }
let(:copy) do
copy = Project.new
copy.name = "foo"
@ -68,9 +62,52 @@ describe Project::Copy do
copy.save
end
it "should copy all relevant attributes from another project" do
copy.types.should == project.types
copy.work_package_custom_fields.should == project.work_package_custom_fields
describe :types do
subject { copy.types }
it { should == project.types }
end
describe :work_package_custom_fields do
let(:project) do
project = FactoryGirl.create(:project_with_types)
work_package_custom_field = FactoryGirl.create(:work_package_custom_field)
project.work_package_custom_fields << work_package_custom_field
project.save
project
end
subject { copy.work_package_custom_fields }
it { should == project.work_package_custom_fields }
end
describe :is_public do
describe :non_public do
let(:project) do
project = FactoryGirl.create(:project_with_types)
project.is_public = false
project.save
project
end
subject { copy.is_public }
it { copy.is_public?.should == project.is_public? }
end
describe :public do
let(:project) do
project = FactoryGirl.create(:project_with_types)
project.is_public = true
project.save
project
end
subject { copy.is_public }
it { copy.is_public?.should == project.is_public? }
end
end
end
@ -120,5 +157,130 @@ describe Project::Copy do
it { should == project.timelines.count }
end
describe :copy_queries do
before do
FactoryGirl.create(:query, :project => project)
copy.send(:copy_queries, project)
copy.save
end
subject { copy.queries.count }
it { should == project.queries.count }
end
describe :copy_members do
describe :with_user do
before do
role = FactoryGirl.create(:role)
user = FactoryGirl.create(:user, member_in_project: project, member_through_role: role)
copy.send(:copy_members, project)
copy.save
end
subject { copy.members.count }
it { should == project.members.count }
end
describe :with_group do
before do
project.add_member! FactoryGirl.create(:group), FactoryGirl.create(:role)
copy.send(:copy_members, project)
copy.save
end
subject { copy.principals.count }
it { should == project.principals.count }
end
end
describe :copy_wiki do
before do
project.wiki = FactoryGirl.create(:wiki, project: project)
project.save
copy.send(:copy_wiki, project)
copy.save
end
subject { copy.wiki }
it { should_not == nil && should.be_valid }
end
describe :copy_boards do
before do
FactoryGirl.create(:board, project: project)
copy.send(:copy_boards, project)
copy.save
end
subject { copy.boards.count }
it { should == project.boards.count }
end
describe :copy_versions do
before do
FactoryGirl.create(:version, project: project)
copy.send(:copy_versions, project)
copy.save
end
subject { copy.versions.count }
it { should == project.versions.count }
end
describe :copy_project_associations do
let(:project2) { FactoryGirl.create(:project_with_types) }
describe :project_a_associations do
before do
FactoryGirl.create(:project_association, project_a: project, project_b: project2)
copy.send(:copy_project_associations, project)
copy.save
end
subject { copy.send(:project_a_associations).count }
it { should == project.send(:project_a_associations).count }
end
describe :project_b_associations do
before do
FactoryGirl.create(:project_association, project_a: project2, project_b: project)
copy.send(:copy_project_associations, project)
copy.save
end
subject { copy.send(:project_b_associations).count }
it { should == project.send(:project_b_associations).count }
end
end
describe :copy_categories do
before do
FactoryGirl.create(:category, project: project)
copy.send(:copy_categories, project)
copy.save
end
subject { copy.categories.count }
it { should == project.categories.count }
end
end
end
Loading…
Cancel
Save