From b58155113b46690d9390597f9f1feccf44b00989 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Mon, 10 Sep 2012 06:35:23 -0700 Subject: [PATCH] add spinach steps for remaining features --- features/project/deploy_keys.feature | 0 features/project/merge_requests.feature | 6 +- features/project/network.feature | 5 +- features/project/project.feature | 13 +-- features/project/snippets.feature | 0 features/project/team_management.feature | 15 ++-- features/project/wall.feature | 5 +- features/project/web_hooks.feature | 0 features/project/wiki.feature | 6 +- features/steps/create_project.rb | 27 ++++++ features/steps/project.rb | 15 ++++ features/steps/project_merge_requests.rb | 102 ++++++++++++++++++++++ features/steps/project_network_graph.rb | 28 ++++++ features/steps/project_team_management.rb | 98 +++++++++++++++++++++ features/steps/project_wall.rb | 24 +++++ features/steps/project_wiki.rb | 37 ++++++++ 16 files changed, 357 insertions(+), 24 deletions(-) delete mode 100644 features/project/deploy_keys.feature delete mode 100644 features/project/snippets.feature delete mode 100644 features/project/web_hooks.feature create mode 100644 features/steps/create_project.rb create mode 100644 features/steps/project.rb create mode 100644 features/steps/project_merge_requests.rb create mode 100644 features/steps/project_network_graph.rb create mode 100644 features/steps/project_team_management.rb create mode 100644 features/steps/project_wall.rb create mode 100644 features/steps/project_wiki.rb diff --git a/features/project/deploy_keys.feature b/features/project/deploy_keys.feature deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/features/project/merge_requests.feature b/features/project/merge_requests.feature index 54b6ccde7f9..80f00986466 100644 --- a/features/project/merge_requests.feature +++ b/features/project/merge_requests.feature @@ -1,10 +1,10 @@ -Feature: Merge Requests +Feature: Project Merge Requests Background: - Given I signin as a user + Given I sign in as a user And I own project "Shop" And project "Shop" have "Bug NS-04" open merge request And project "Shop" have "Feature NS-03" closed merge request - And I visit project "Shop" merge requests page + And I visit project "Shop" merge requests page Scenario: I should see open merge requests Then I should see "Bug NS-04" in merge requests diff --git a/features/project/network.feature b/features/project/network.feature index 61c05eb367e..31ce5ad3279 100644 --- a/features/project/network.feature +++ b/features/project/network.feature @@ -1,10 +1,9 @@ -@javascript Feature: Project Network Graph - Background: - Given I signin as a user + Given I sign in as a user And I own project "Shop" And I visit project "Shop" network page + @javascript Scenario: I should see project network Then page should have network graph diff --git a/features/project/project.feature b/features/project/project.feature index 895a928ff81..1c9f201df50 100644 --- a/features/project/project.feature +++ b/features/project/project.feature @@ -1,11 +1,14 @@ -Feature: Project +Feature: Projects Background: Given I signin as a user And I own project "Shop" - And I visit project "Shop" page + And I visit project "Shop" page - Scenario: I should see project activity + # @wip + # Scenario: I should see project activity - Scenario: I edit project + # @wip + # Scenario: I edit project - Scenario: I visit attachments + # @wip + # Scenario: I visit attachments diff --git a/features/project/snippets.feature b/features/project/snippets.feature deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/features/project/team_management.feature b/features/project/team_management.feature index b5b485e2dc0..ae0c459f333 100644 --- a/features/project/team_management.feature +++ b/features/project/team_management.feature @@ -1,11 +1,11 @@ Feature: Project Team management - Background: - Given I signin as a user + Background: + Given I sign in as a user And I own project "Shop" - And gitlab user "Mike" - And gitlab user "Sam" + And gitlab user "Mike" + And gitlab user "Sam" And "Sam" is "Shop" developer - And I visit project "Shop" team page + And I visit project "Shop" team page Scenario: See all team members Then I should be able to see myself in team @@ -20,7 +20,7 @@ Feature: Project Team management Scenario: Update user access Given I should see "Sam" in team list as "Developer" And I change "Sam" role to "Reporter" - Then I visit project "Shop" team page + Then I visit project "Shop" team page And I should see "Sam" in team list as "Reporter" Scenario: View team member profile @@ -30,6 +30,5 @@ Feature: Project Team management Scenario: Cancel team member Given I click link "Sam" And I click link "Remove from team" - Then I visit project "Shop" team page + Then I visit project "Shop" team page And I should not see "Sam" in team list - diff --git a/features/project/wall.feature b/features/project/wall.feature index ed675e2c477..c92dbf82db5 100644 --- a/features/project/wall.feature +++ b/features/project/wall.feature @@ -7,11 +7,12 @@ Feature: Project Wall Background: Given I signin as a user And I own project "Shop" - And I visit project "Shop" wall page + And I visit project "Shop" wall page + @javascript Scenario: Write comment Given I write new comment "my special test message" Then I should see project wall note "my special test message" - Then I visit project "Shop" wall page + Then I visit project "Shop" wall page And I should see project wall note "my special test message" diff --git a/features/project/web_hooks.feature b/features/project/web_hooks.feature deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/features/project/wiki.feature b/features/project/wiki.feature index 4441ada2847..51370565a3b 100644 --- a/features/project/wiki.feature +++ b/features/project/wiki.feature @@ -1,6 +1,6 @@ -Feature: Wiki - Background: - Given I signin as a user +Feature: Project Wiki + Background: + Given I sign in as a user And I own project "Shop" Given I visit project wiki page diff --git a/features/steps/create_project.rb b/features/steps/create_project.rb new file mode 100644 index 00000000000..80f6f7088ec --- /dev/null +++ b/features/steps/create_project.rb @@ -0,0 +1,27 @@ +class CreateProject < Spinach::FeatureSteps + Given 'I signin as a user' do + login_as :user + end + + When 'I visit new project page' do + visit new_project_path + end + + And 'fill project form with valid data' do + fill_in 'project_name', :with => 'NewProject' + fill_in 'project_code', :with => 'NPR' + fill_in 'project_path', :with => 'newproject' + click_button "Create project" + end + + Then 'I should see project page' do + current_path.should == project_path(Project.last) + page.should have_content('NewProject') + end + + And 'I should see empty project instuctions' do + page.should have_content "git init" + page.should have_content "git remote" + page.should have_content Project.last.url_to_repo + end +end diff --git a/features/steps/project.rb b/features/steps/project.rb new file mode 100644 index 00000000000..666a65fadc4 --- /dev/null +++ b/features/steps/project.rb @@ -0,0 +1,15 @@ +class Projects < Spinach::FeatureSteps + Given 'I sign in as a user' do + login_as :user + end + + And 'I own project "Shop"' do + @project = Factory :project, :name => "Shop" + @project.add_access(@user, :admin) + end + + And 'I visit project "Shop" page' do + project = Project.find_by_name("Shop") + visit project_path(project) + end +end diff --git a/features/steps/project_merge_requests.rb b/features/steps/project_merge_requests.rb new file mode 100644 index 00000000000..8515e7e8a1c --- /dev/null +++ b/features/steps/project_merge_requests.rb @@ -0,0 +1,102 @@ +class ProjectMergeRequests < Spinach::FeatureSteps + Then 'I should see "Bug NS-04" in merge requests' do + page.should have_content "Bug NS-04" + end + + And 'I should not see "Feature NS-03" in merge requests' do + page.should_not have_content "Feature NS-03" + end + + Given 'I click link "Closed"' do + click_link "Closed" + end + + Then 'I should see "Feature NS-03" in merge requests' do + page.should have_content "Feature NS-03" + end + + And 'I should not see "Bug NS-04" in merge requests' do + page.should_not have_content "Bug NS-04" + end + + Given 'I click link "All"' do + click_link "All" + end + + Given 'I click link "Bug NS-04"' do + click_link "Bug NS-04" + end + + Then 'I should see merge request "Bug NS-04"' do + page.should have_content "Bug NS-04" + end + + And 'I click link "Close"' do + click_link "Close" + end + + Then 'I should see closed merge request "Bug NS-04"' do + mr = MergeRequest.find_by_title("Bug NS-04") + mr.closed.should be_true + page.should have_content "Closed by" + end + + Given 'I click link "New Merge Request"' do + click_link "New Merge Request" + end + + And 'I submit new merge request "Wiki Feature"' do + fill_in "merge_request_title", :with => "Wiki Feature" + select "master", :from => "merge_request_source_branch" + select "stable", :from => "merge_request_target_branch" + click_button "Save" + end + + Then 'I should see merge request "Wiki Feature"' do + page.should have_content "Wiki Feature" + end + + Given 'I visit merge request page "Bug NS-04"' do + mr = MergeRequest.find_by_title("Bug NS-04") + visit project_merge_request_path(mr.project, mr) + end + + And 'I leave a comment like "XML attached"' do + fill_in "note_note", :with => "XML attached" + click_button "Add Comment" + end + + Then 'I should see comment "XML attached"' do + page.should have_content "XML attached" + end + + Given 'I sign in as a user' do + login_as :user + end + + And 'I own project "Shop"' do + @project = Factory :project, :name => "Shop" + @project.add_access(@user, :admin) + end + + And 'project "Shop" have "Bug NS-04" open merge request' do + project = Project.find_by_name("Shop") + Factory.create(:merge_request, + :title => "Bug NS-04", + :project => project, + :author => project.users.first) + end + + And 'project "Shop" have "Feature NS-03" closed merge request' do + project = Project.find_by_name("Shop") + Factory.create(:merge_request, + :title => "Feature NS-03", + :project => project, + :author => project.users.first, + :closed => true) + end + + And 'I visit project "Shop" merge requests page' do + visit project_merge_requests_path(Project.find_by_name("Shop")) + end +end diff --git a/features/steps/project_network_graph.rb b/features/steps/project_network_graph.rb new file mode 100644 index 00000000000..d87f3d82951 --- /dev/null +++ b/features/steps/project_network_graph.rb @@ -0,0 +1,28 @@ +class ProjectNetworkGraph < Spinach::FeatureSteps + Then 'page should have network graph' do + page.should have_content "Project Network Graph" + within ".graph" do + page.should have_content "master" + page.should have_content "scss_refactor..." + end + end + + Given 'I sign in as a user' do + login_as :user + end + + And 'I own project "Shop"' do + @project = Factory :project, :name => "Shop" + @project.add_access(@user, :admin) + end + + And 'I visit project "Shop" network page' do + project = Project.find_by_name("Shop") + + # Stub out find_all to speed this up (10 commits vs. 650) + commits = Grit::Commit.find_all(project.repo, nil, {max_count: 10}) + Grit::Commit.stub(:find_all).and_return(commits) + + visit graph_project_path(project) + end +end diff --git a/features/steps/project_team_management.rb b/features/steps/project_team_management.rb new file mode 100644 index 00000000000..9cee75bd9f8 --- /dev/null +++ b/features/steps/project_team_management.rb @@ -0,0 +1,98 @@ +class ProjectTeamManagement < Spinach::FeatureSteps + Then 'I should be able to see myself in team' do + page.should have_content(@user.name) + page.should have_content(@user.email) + end + + And 'I should see "Sam" in team list' do + user = User.find_by_name("Sam") + page.should have_content(user.name) + page.should have_content(user.email) + end + + Given 'I click link "New Team Member"' do + click_link "New Team Member" + end + + And 'I select "Mike" as "Reporter"' do + user = User.find_by_name("Mike") + within "#new_team_member" do + select user.name, :from => "user_ids" + select "Reporter", :from => "project_access" + end + click_button "Save" + end + + Then 'I should see "Mike" in team list as "Reporter"' do + user = User.find_by_name("Mike") + role_id = find(".user_#{user.id} #team_member_project_access").value + role_id.should == UsersProject.access_roles["Reporter"].to_s + end + + Given 'I should see "Sam" in team list as "Developer"' do + user = User.find_by_name("Sam") + role_id = find(".user_#{user.id} #team_member_project_access").value + role_id.should == UsersProject.access_roles["Developer"].to_s + end + + And 'I change "Sam" role to "Reporter"' do + user = User.find_by_name("Sam") + within ".user_#{user.id}" do + select "Reporter", :from => "team_member_project_access" + end + end + + Then 'I visit project "Shop" team page' do + visit team_project_path(Project.find_by_name("Shop")) + end + + And 'I should see "Sam" in team list as "Reporter"' do + user = User.find_by_name("Sam") + role_id = find(".user_#{user.id} #team_member_project_access").value + role_id.should == UsersProject.access_roles["Reporter"].to_s + end + + Given 'I click link "Sam"' do + click_link "Sam" + end + + Then 'I should see "Sam" team profile' do + user = User.find_by_name("Sam") + page.should have_content(user.name) + page.should have_content(user.email) + page.should have_content("To team list") + end + + And 'I click link "Remove from team"' do + click_link "Remove from team" + end + + And 'I should not see "Sam" in team list' do + user = User.find_by_name("Sam") + page.should_not have_content(user.name) + page.should_not have_content(user.email) + end + + Given 'I sign in as a user' do + login_as :user + end + + And 'I own project "Shop"' do + @project = Factory :project, :name => "Shop" + @project.add_access(@user, :admin) + end + + And 'gitlab user "Mike"' do + Factory :user, :name => "Mike" + end + + And 'gitlab user "Sam"' do + Factory :user, :name => "Sam" + end + + And '"Sam" is "Shop" developer' do + user = User.find_by_name("Sam") + project = Project.find_by_name("Shop") + project.add_access(user, :write) + end +end diff --git a/features/steps/project_wall.rb b/features/steps/project_wall.rb new file mode 100644 index 00000000000..b94bd0bb1ef --- /dev/null +++ b/features/steps/project_wall.rb @@ -0,0 +1,24 @@ +class ProjectWall < Spinach::FeatureSteps + Given 'I write new comment "my special test message"' do + fill_in "note_note", :with => "my special test message" + click_button "Add Comment" + end + + Then 'I should see project wall note "my special test message"' do + page.should have_content "my special test message" + end + + Then 'I visit project "Shop" wall page' do + project = Project.find_by_name("Shop") + visit wall_project_path(project) + end + + Given 'I signin as a user' do + login_as :user + end + + And 'I own project "Shop"' do + @project = Factory :project, :name => "Shop" + @project.add_access(@user, :admin) + end +end diff --git a/features/steps/project_wiki.rb b/features/steps/project_wiki.rb new file mode 100644 index 00000000000..8c8c7c8d78d --- /dev/null +++ b/features/steps/project_wiki.rb @@ -0,0 +1,37 @@ +class ProjectWiki < Spinach::FeatureSteps + Given 'I create Wiki page' do + fill_in "Title", :with => 'Test title' + fill_in "Content", :with => '[link test](test)' + click_on "Save" + end + + Then 'I should see newly created wiki page' do + page.should have_content "Test title" + page.should have_content "link test" + + click_link "link test" + page.should have_content "Editing page" + end + + And 'I leave a comment like "XML attached"' do + fill_in "note_note", :with => "XML attached" + click_button "Add Comment" + end + + Then 'I should see comment "XML attached"' do + page.should have_content "XML attached" + end + + Given 'I sign in as a user' do + login_as :user + end + + And 'I own project "Shop"' do + @project = Factory :project, :name => "Shop" + @project.add_access(@user, :admin) + end + + Given 'I visit project wiki page' do + visit project_wiki_path(@project, :index) + end +end