From 79eb5ab396690c613ea6e13c3c941ba1fa80f217 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Mon, 10 Sep 2012 08:35:03 -0700 Subject: refactor feature steps --- features/project/create_project.feature | 2 +- features/project/wall.feature | 6 +- features/steps/create_project.rb | 27 ---- features/steps/dashboard.rb | 97 ------------- features/steps/dashboard/dashboard.rb | 92 ++++++++++++ features/steps/dashboard/dashboard_issues.rb | 19 +++ .../steps/dashboard/dashboard_merge_requests.rb | 23 +++ features/steps/dashboard/dashboard_search.rb | 18 +++ features/steps/dashboard_issues.rb | 32 ----- features/steps/dashboard_merge_requests.rb | 33 ----- features/steps/dashboard_search.rb | 23 --- features/steps/profile.rb | 57 -------- features/steps/profile/profile.rb | 44 ++++++ features/steps/profile/profile_ssh_keys.rb | 48 +++++++ features/steps/profile_ssh_keys.rb | 50 ------- features/steps/project.rb | 15 -- features/steps/project/create_project.rb | 22 +++ features/steps/project/project.rb | 5 + features/steps/project/project_browse_branches.rb | 35 +++++ features/steps/project/project_browse_commits.rb | 47 ++++++ features/steps/project/project_browse_files.rb | 34 +++++ features/steps/project/project_browse_git_repo.rb | 19 +++ features/steps/project/project_browse_tags.rb | 10 ++ features/steps/project/project_comment_commit.rb | 6 + features/steps/project/project_issues.rb | 134 +++++++++++++++++ features/steps/project/project_labels.rb | 24 ++++ features/steps/project/project_merge_requests.rb | 80 +++++++++++ features/steps/project/project_milestones.rb | 39 +++++ features/steps/project/project_network_graph.rb | 22 +++ features/steps/project/project_team_management.rb | 89 ++++++++++++ features/steps/project/project_wall.rb | 6 + features/steps/project/project_wiki.rb | 20 +++ features/steps/project_browse_branches.rb | 44 ------ features/steps/project_browse_commits.rb | 60 -------- features/steps/project_browse_files.rb | 51 ------- features/steps/project_browse_git_repo.rb | 28 ---- features/steps/project_browse_tags.rb | 19 --- features/steps/project_comment_commit.rb | 23 --- features/steps/project_issues.rb | 160 --------------------- features/steps/project_labels.rb | 33 ----- features/steps/project_merge_requests.rb | 102 ------------- features/steps/project_milestones.rb | 51 ------- 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 ----- features/steps/shared/authentication.rb | 10 ++ features/steps/shared/note.rb | 21 +++ features/steps/shared/paths.rb | 112 +++++++++++++++ features/steps/shared/project.rb | 8 ++ features/support/env.rb | 5 +- 51 files changed, 993 insertions(+), 1099 deletions(-) delete mode 100644 features/steps/create_project.rb delete mode 100644 features/steps/dashboard.rb create mode 100644 features/steps/dashboard/dashboard.rb create mode 100644 features/steps/dashboard/dashboard_issues.rb create mode 100644 features/steps/dashboard/dashboard_merge_requests.rb create mode 100644 features/steps/dashboard/dashboard_search.rb delete mode 100644 features/steps/dashboard_issues.rb delete mode 100644 features/steps/dashboard_merge_requests.rb delete mode 100644 features/steps/dashboard_search.rb delete mode 100644 features/steps/profile.rb create mode 100644 features/steps/profile/profile.rb create mode 100644 features/steps/profile/profile_ssh_keys.rb delete mode 100644 features/steps/profile_ssh_keys.rb delete mode 100644 features/steps/project.rb create mode 100644 features/steps/project/create_project.rb create mode 100644 features/steps/project/project.rb create mode 100644 features/steps/project/project_browse_branches.rb create mode 100644 features/steps/project/project_browse_commits.rb create mode 100644 features/steps/project/project_browse_files.rb create mode 100644 features/steps/project/project_browse_git_repo.rb create mode 100644 features/steps/project/project_browse_tags.rb create mode 100644 features/steps/project/project_comment_commit.rb create mode 100644 features/steps/project/project_issues.rb create mode 100644 features/steps/project/project_labels.rb create mode 100644 features/steps/project/project_merge_requests.rb create mode 100644 features/steps/project/project_milestones.rb create mode 100644 features/steps/project/project_network_graph.rb create mode 100644 features/steps/project/project_team_management.rb create mode 100644 features/steps/project/project_wall.rb create mode 100644 features/steps/project/project_wiki.rb delete mode 100644 features/steps/project_browse_branches.rb delete mode 100644 features/steps/project_browse_commits.rb delete mode 100644 features/steps/project_browse_files.rb delete mode 100644 features/steps/project_browse_git_repo.rb delete mode 100644 features/steps/project_browse_tags.rb delete mode 100644 features/steps/project_comment_commit.rb delete mode 100644 features/steps/project_issues.rb delete mode 100644 features/steps/project_labels.rb delete mode 100644 features/steps/project_merge_requests.rb delete mode 100644 features/steps/project_milestones.rb delete mode 100644 features/steps/project_network_graph.rb delete mode 100644 features/steps/project_team_management.rb delete mode 100644 features/steps/project_wall.rb delete mode 100644 features/steps/project_wiki.rb create mode 100644 features/steps/shared/authentication.rb create mode 100644 features/steps/shared/note.rb create mode 100644 features/steps/shared/paths.rb create mode 100644 features/steps/shared/project.rb diff --git a/features/project/create_project.feature b/features/project/create_project.feature index 42d25b3f331..b7cdfdb818e 100644 --- a/features/project/create_project.feature +++ b/features/project/create_project.feature @@ -4,7 +4,7 @@ Feature: Create Project Should be able to create a new one Scenario: User create a project - Given I signin as a user + Given I sign in as a user When I visit new project page And fill project form with valid data Then I should see project page diff --git a/features/project/wall.feature b/features/project/wall.feature index c92dbf82db5..c38d046a850 100644 --- a/features/project/wall.feature +++ b/features/project/wall.feature @@ -1,11 +1,9 @@ -@javascript Feature: Project Wall In order to use Project Wall - A user - Should be able to read & write messages + A user should be able to read and write messages Background: - Given I signin as a user + Given I sign in as a user And I own project "Shop" And I visit project "Shop" wall page diff --git a/features/steps/create_project.rb b/features/steps/create_project.rb deleted file mode 100644 index 80f6f7088ec..00000000000 --- a/features/steps/create_project.rb +++ /dev/null @@ -1,27 +0,0 @@ -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/dashboard.rb b/features/steps/dashboard.rb deleted file mode 100644 index e69686b32b4..00000000000 --- a/features/steps/dashboard.rb +++ /dev/null @@ -1,97 +0,0 @@ -class Dashboard < Spinach::FeatureSteps - Then 'I should see "New Project" link' do - page.should have_link "New Project" - end - - Then 'I should see "Shop" project link' do - page.should have_link "Shop" - end - - Then 'I should see project "Shop" activity feed' do - project = Project.find_by_name("Shop") - page.should have_content "#{@user.name} pushed new branch new_design at #{project.name}" - end - - Then 'I should see last push widget' do - page.should have_content "Your pushed to branch new_design" - page.should have_link "Create Merge Request" - end - - And 'I click "Create Merge Request" link' do - click_link "Create Merge Request" - end - - Then 'I see prefilled new Merge Request page' do - current_path.should == new_project_merge_request_path(@project) - find("#merge_request_source_branch").value.should == "new_design" - find("#merge_request_target_branch").value.should == "master" - find("#merge_request_title").value.should == "New Design" - end - - Given 'user with name "John Doe" joined project "Shop"' do - user = Factory.create(:user, {name: "John Doe"}) - project = Project.find_by_name "Shop" - Event.create( - project: project, - author_id: user.id, - action: Event::Joined - ) - end - - When 'I visit dashboard page' do - visit dashboard_path - end - - Then 'I should see "John Doe joined project Shop" event' do - page.should have_content "John Doe joined project Shop" - end - - And 'user with name "John Doe" left project "Shop"' do - user = User.find_by_name "John Doe" - project = Project.find_by_name "Shop" - Event.create( - project: project, - author_id: user.id, - action: Event::Left - ) - end - - Then 'I should see "John Doe left project Shop" event' do - page.should have_content "John Doe left project Shop" - 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" has push event' do - @project = Project.find_by_name("Shop") - - data = { - :before => "0000000000000000000000000000000000000000", - :after => "0220c11b9a3e6c69dc8fd35321254ca9a7b98f7e", - :ref => "refs/heads/new_design", - :user_id => @user.id, - :user_name => @user.name, - :repository => { - :name => @project.name, - :url => "localhost/rubinius", - :description => "", - :homepage => "localhost/rubinius", - :private => true - } - } - - @event = Event.create( - :project => @project, - :action => Event::Pushed, - :data => data, - :author_id => @user.id - ) - end -end diff --git a/features/steps/dashboard/dashboard.rb b/features/steps/dashboard/dashboard.rb new file mode 100644 index 00000000000..6c603bbea55 --- /dev/null +++ b/features/steps/dashboard/dashboard.rb @@ -0,0 +1,92 @@ +class Dashboard < Spinach::FeatureSteps + include SharedAuthentication + include SharedPaths + + Then 'I should see "New Project" link' do + page.should have_link "New Project" + end + + Then 'I should see "Shop" project link' do + page.should have_link "Shop" + end + + Then 'I should see project "Shop" activity feed' do + project = Project.find_by_name("Shop") + page.should have_content "#{@user.name} pushed new branch new_design at #{project.name}" + end + + Then 'I should see last push widget' do + page.should have_content "Your pushed to branch new_design" + page.should have_link "Create Merge Request" + end + + And 'I click "Create Merge Request" link' do + click_link "Create Merge Request" + end + + Then 'I see prefilled new Merge Request page' do + current_path.should == new_project_merge_request_path(@project) + find("#merge_request_source_branch").value.should == "new_design" + find("#merge_request_target_branch").value.should == "master" + find("#merge_request_title").value.should == "New Design" + end + + Given 'user with name "John Doe" joined project "Shop"' do + user = Factory.create(:user, {name: "John Doe"}) + project = Project.find_by_name "Shop" + Event.create( + project: project, + author_id: user.id, + action: Event::Joined + ) + end + + Then 'I should see "John Doe joined project Shop" event' do + page.should have_content "John Doe joined project Shop" + end + + And 'user with name "John Doe" left project "Shop"' do + user = User.find_by_name "John Doe" + project = Project.find_by_name "Shop" + Event.create( + project: project, + author_id: user.id, + action: Event::Left + ) + end + + Then 'I should see "John Doe left project Shop" event' do + page.should have_content "John Doe left project Shop" + end + + And 'I own project "Shop"' do + @project = Factory :project, :name => 'Shop' + @project.add_access(@user, :admin) + end + + And 'project "Shop" has push event' do + @project = Project.find_by_name("Shop") + + data = { + :before => "0000000000000000000000000000000000000000", + :after => "0220c11b9a3e6c69dc8fd35321254ca9a7b98f7e", + :ref => "refs/heads/new_design", + :user_id => @user.id, + :user_name => @user.name, + :repository => { + :name => @project.name, + :url => "localhost/rubinius", + :description => "", + :homepage => "localhost/rubinius", + :private => true + } + } + + @event = Event.create( + :project => @project, + :action => Event::Pushed, + :data => data, + :author_id => @user.id + ) + end +end diff --git a/features/steps/dashboard/dashboard_issues.rb b/features/steps/dashboard/dashboard_issues.rb new file mode 100644 index 00000000000..9368782bf99 --- /dev/null +++ b/features/steps/dashboard/dashboard_issues.rb @@ -0,0 +1,19 @@ +class DashboardIssues < Spinach::FeatureSteps + include SharedAuthentication + include SharedPaths + + Then 'I should see issues assigned to me' do + issues = @user.issues + issues.each do |issue| + page.should have_content(issue.title[0..10]) + page.should have_content(issue.project.name) + end + end + + And 'I have assigned issues' do + project = Factory :project + project.add_access(@user, :read, :write) + + 2.times { Factory :issue, :author => @user, :assignee => @user, :project => project } + end +end diff --git a/features/steps/dashboard/dashboard_merge_requests.rb b/features/steps/dashboard/dashboard_merge_requests.rb new file mode 100644 index 00000000000..fc339e756d8 --- /dev/null +++ b/features/steps/dashboard/dashboard_merge_requests.rb @@ -0,0 +1,23 @@ +class DashboardMergeRequests < Spinach::FeatureSteps + include SharedAuthentication + include SharedPaths + + Then 'I should see my merge requests' do + merge_requests = @user.merge_requests + merge_requests.each do |mr| + page.should have_content(mr.title[0..10]) + page.should have_content(mr.project.name) + end + end + + And 'I have authored merge requests' do + project1 = Factory :project + project2 = Factory :project + + project1.add_access(@user, :read, :write) + project2.add_access(@user, :read, :write) + + merge_request1 = Factory :merge_request, :author => @user, :project => project1 + merge_request2 = Factory :merge_request, :author => @user, :project => project2 + end +end diff --git a/features/steps/dashboard/dashboard_search.rb b/features/steps/dashboard/dashboard_search.rb new file mode 100644 index 00000000000..e35858985d6 --- /dev/null +++ b/features/steps/dashboard/dashboard_search.rb @@ -0,0 +1,18 @@ +class DashboardSearch < Spinach::FeatureSteps + include SharedAuthentication + include SharedPaths + + Given 'I search for "Sho"' do + fill_in "dashboard_search", :with => "Sho" + click_button "Search" + end + + Then 'I should see "Shop" project link' do + page.should have_link "Shop" + end + + And 'I own project "Shop"' do + @project = Factory :project, :name => "Shop" + @project.add_access(@user, :admin) + end +end diff --git a/features/steps/dashboard_issues.rb b/features/steps/dashboard_issues.rb deleted file mode 100644 index 8704d2efdf6..00000000000 --- a/features/steps/dashboard_issues.rb +++ /dev/null @@ -1,32 +0,0 @@ -class DashboardIssues < Spinach::FeatureSteps - Then 'I should see issues assigned to me' do - issues = @user.issues - issues.each do |issue| - page.should have_content(issue.title[0..10]) - page.should have_content(issue.project.name) - end - end - - Given 'I sign in as a user' do - login_as :user - end - - And 'I have assigned issues' do - project = Factory :project - project.add_access(@user, :read, :write) - - issue1 = Factory :issue, - :author => @user, - :assignee => @user, - :project => project - - issue2 = Factory :issue, - :author => @user, - :assignee => @user, - :project => project - end - - And 'I visit dashboard issues page' do - visit dashboard_issues_path - end -end diff --git a/features/steps/dashboard_merge_requests.rb b/features/steps/dashboard_merge_requests.rb deleted file mode 100644 index 3e057ef9109..00000000000 --- a/features/steps/dashboard_merge_requests.rb +++ /dev/null @@ -1,33 +0,0 @@ -class DashboardMergeRequests < Spinach::FeatureSteps - Then 'I should see my merge requests' do - merge_requests = @user.merge_requests - merge_requests.each do |mr| - page.should have_content(mr.title[0..10]) - page.should have_content(mr.project.name) - end - end - - Given 'I sign in as a user' do - login_as :user - end - - And 'I have authored merge requests' do - project1 = Factory :project - project2 = Factory :project - - project1.add_access(@user, :read, :write) - project2.add_access(@user, :read, :write) - - merge_request1 = Factory :merge_request, - :author => @user, - :project => project1 - - merge_request2 = Factory :merge_request, - :author => @user, - :project => project2 - end - - And 'I visit dashboard merge requests page' do - visit dashboard_merge_requests_path - end -end diff --git a/features/steps/dashboard_search.rb b/features/steps/dashboard_search.rb deleted file mode 100644 index 122774fc23c..00000000000 --- a/features/steps/dashboard_search.rb +++ /dev/null @@ -1,23 +0,0 @@ -class DashboardSearch < Spinach::FeatureSteps - Given 'I search for "Sho"' do - fill_in "dashboard_search", :with => "Sho" - click_button "Search" - end - - Then 'I should see "Shop" project link' do - page.should have_link "Shop" - 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 dashboard search page' do - visit search_path - end -end diff --git a/features/steps/profile.rb b/features/steps/profile.rb deleted file mode 100644 index c7e6be3fdea..00000000000 --- a/features/steps/profile.rb +++ /dev/null @@ -1,57 +0,0 @@ -class Profile < Spinach::FeatureSteps - Given 'I visit profile page' do - visit profile_path - end - - Then 'I should see my profile info' do - page.should have_content "Profile" - page.should have_content @user.name - page.should have_content @user.email - end - - Then 'I change my contact info' do - fill_in "user_skype", :with => "testskype" - fill_in "user_linkedin", :with => "testlinkedin" - fill_in "user_twitter", :with => "testtwitter" - click_button "Save" - @user.reload - end - - And 'I should see new contact info' do - @user.skype.should == 'testskype' - @user.linkedin.should == 'testlinkedin' - @user.twitter.should == 'testtwitter' - end - - Given 'I visit profile password page' do - visit profile_password_path - end - - Then 'I change my password' do - fill_in "user_password", :with => "222333" - fill_in "user_password_confirmation", :with => "222333" - click_button "Save" - end - - And 'I should be redirected to sign in page' do - current_path.should == new_user_session_path - end - - Given 'I visit profile token page' do - visit profile_token_path - end - - Then 'I reset my token' do - @old_token = @user.private_token - click_button "Reset" - end - - And 'I should see new token' do - find("#token").value.should_not == @old_token - find("#token").value.should == @user.reload.private_token - end - - Given 'I sign in as a user' do - login_as :user - end -end diff --git a/features/steps/profile/profile.rb b/features/steps/profile/profile.rb new file mode 100644 index 00000000000..d3261a16690 --- /dev/null +++ b/features/steps/profile/profile.rb @@ -0,0 +1,44 @@ +class Profile < Spinach::FeatureSteps + include SharedAuthentication + include SharedPaths + + Then 'I should see my profile info' do + page.should have_content "Profile" + page.should have_content @user.name + page.should have_content @user.email + end + + Then 'I change my contact info' do + fill_in "user_skype", :with => "testskype" + fill_in "user_linkedin", :with => "testlinkedin" + fill_in "user_twitter", :with => "testtwitter" + click_button "Save" + @user.reload + end + + And 'I should see new contact info' do + @user.skype.should == 'testskype' + @user.linkedin.should == 'testlinkedin' + @user.twitter.should == 'testtwitter' + end + + Then 'I change my password' do + fill_in "user_password", :with => "222333" + fill_in "user_password_confirmation", :with => "222333" + click_button "Save" + end + + And 'I should be redirected to sign in page' do + current_path.should == new_user_session_path + end + + Then 'I reset my token' do + @old_token = @user.private_token + click_button "Reset" + end + + And 'I should see new token' do + find("#token").value.should_not == @old_token + find("#token").value.should == @user.reload.private_token + end +end diff --git a/features/steps/profile/profile_ssh_keys.rb b/features/steps/profile/profile_ssh_keys.rb new file mode 100644 index 00000000000..96df2d7342f --- /dev/null +++ b/features/steps/profile/profile_ssh_keys.rb @@ -0,0 +1,48 @@ +class ProfileSshKeys < Spinach::FeatureSteps + include SharedAuthentication + + Then 'I should see my ssh keys' do + @user.keys.each do |key| + page.should have_content(key.title) + end + end + + Given 'I click link "Add new"' do + click_link "Add new" + end + + And 'I submit new ssh key "Laptop"' do + fill_in "key_title", :with => "Laptop" + fill_in "key_key", :with => "ssh-rsa publickey234=" + click_button "Save" + end + + Then 'I should see new ssh key "Laptop"' do + key = Key.find_by_title("Laptop") + page.should have_content(key.title) + page.should have_content(key.key) + current_path.should == key_path(key) + end + + Given 'I click link "Work"' do + click_link "Work" + end + + And 'I click link "Remove"' do + click_link "Remove" + end + + Then 'I visit profile keys page' do + visit keys_path + end + + And 'I should not see "Work" ssh key' do + within "#keys-table" do + page.should_not have_content "Work" + end + end + + And 'I have ssh key "ssh-rsa Work"' do + Factory :key, :user => @user, :title => "ssh-rsa Work", :key => "jfKLJDFKSFJSHFJssh-rsa Work" + end +end diff --git a/features/steps/profile_ssh_keys.rb b/features/steps/profile_ssh_keys.rb deleted file mode 100644 index 9360f66f766..00000000000 --- a/features/steps/profile_ssh_keys.rb +++ /dev/null @@ -1,50 +0,0 @@ -class ProfileSshKeys < Spinach::FeatureSteps - Then 'I should see my ssh keys' do - @user.keys.each do |key| - page.should have_content(key.title) - end - end - - Given 'I click link "Add new"' do - click_link "Add new" - end - - And 'I submit new ssh key "Laptop"' do - fill_in "key_title", :with => "Laptop" - fill_in "key_key", :with => "ssh-rsa publickey234=" - click_button "Save" - end - - Then 'I should see new ssh key "Laptop"' do - key = Key.find_by_title("Laptop") - page.should have_content(key.title) - page.should have_content(key.key) - current_path.should == key_path(key) - end - - Given 'I click link "Work"' do - click_link "Work" - end - - And 'I click link "Remove"' do - click_link "Remove" - end - - Then 'I visit profile keys page' do - visit keys_path - end - - And 'I should not see "Work" ssh key' do - within "#keys-table" do - page.should_not have_content "Work" - end - end - - Given 'I sign in as a user' do - login_as :user - end - - And 'I have ssh key "ssh-rsa Work"' do - Factory :key, :user => @user, :title => "ssh-rsa Work", :key => "jfKLJDFKSFJSHFJssh-rsa Work" - end -end diff --git a/features/steps/project.rb b/features/steps/project.rb deleted file mode 100644 index 666a65fadc4..00000000000 --- a/features/steps/project.rb +++ /dev/null @@ -1,15 +0,0 @@ -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/create_project.rb b/features/steps/project/create_project.rb new file mode 100644 index 00000000000..6d2ca3f9b56 --- /dev/null +++ b/features/steps/project/create_project.rb @@ -0,0 +1,22 @@ +class CreateProject < Spinach::FeatureSteps + include SharedAuthentication + include SharedPaths + + 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/project.rb b/features/steps/project/project.rb new file mode 100644 index 00000000000..f33f12eb0a8 --- /dev/null +++ b/features/steps/project/project.rb @@ -0,0 +1,5 @@ +class Projects < Spinach::FeatureSteps + include SharedAuthentication + include SharedProject + include SharedPaths +end diff --git a/features/steps/project/project_browse_branches.rb b/features/steps/project/project_browse_branches.rb new file mode 100644 index 00000000000..2f6e185deea --- /dev/null +++ b/features/steps/project/project_browse_branches.rb @@ -0,0 +1,35 @@ +class ProjectBrowseBranches < Spinach::FeatureSteps + include SharedAuthentication + include SharedProject + include SharedPaths + + Then 'I should see "Shop" recent branches list' do + page.should have_content "Branches" + page.should have_content "master" + end + + Given 'I click link "All"' do + click_link "All" + end + + Then 'I should see "Shop" all branches list' do + page.should have_content "Branches" + page.should have_content "master" + end + + Given 'I click link "Protected"' do + click_link "Protected" + end + + Then 'I should see "Shop" protected branches list' do + within "table" do + page.should have_content "stable" + page.should_not have_content "master" + end + end + + And 'project "Shop" has protected branches' do + project = Project.find_by_name("Shop") + project.protected_branches.create(:name => "stable") + end +end diff --git a/features/steps/project/project_browse_commits.rb b/features/steps/project/project_browse_commits.rb new file mode 100644 index 00000000000..014799879e8 --- /dev/null +++ b/features/steps/project/project_browse_commits.rb @@ -0,0 +1,47 @@ +class ProjectBrowseCommits < Spinach::FeatureSteps + include SharedAuthentication + include SharedProject + include SharedPaths + + Then 'I see project commits' do + current_path.should == project_commits_path(@project) + + commit = @project.commit + page.should have_content(@project.name) + page.should have_content(commit.message) + page.should have_content(commit.id.to_s[0..5]) + end + + Given 'I click atom feed link' do + click_link "Feed" + end + + Then 'I see commits atom feed' do + commit = CommitDecorator.decorate(@project.commit) + page.response_headers['Content-Type'].should have_content("application/atom+xml") + page.body.should have_selector("title", :text => "Recent commits to #{@project.name}") + page.body.should have_selector("author email", :text => commit.author_email) + page.body.should have_selector("entry summary", :text => commit.description) + end + + Given 'I click on commit link' do + visit project_commit_path(@project, ValidCommit::ID) + end + + Then 'I see commit info' do + page.should have_content ValidCommit::MESSAGE + page.should have_content "Showing 1 changed file" + end + + And 'I fill compare fields with refs' do + fill_in "from", :with => "master" + fill_in "to", :with => "stable" + click_button "Compare" + end + + And 'I see compared refs' do + page.should have_content "Commits (27)" + page.should have_content "Compare View" + page.should have_content "Showing 73 changed files" + end +end diff --git a/features/steps/project/project_browse_files.rb b/features/steps/project/project_browse_files.rb new file mode 100644 index 00000000000..67c553ced40 --- /dev/null +++ b/features/steps/project/project_browse_files.rb @@ -0,0 +1,34 @@ +class ProjectBrowseFiles < Spinach::FeatureSteps + include SharedAuthentication + include SharedProject + include SharedPaths + + Then 'I should see files from repository' do + page.should have_content "app" + page.should have_content "History" + page.should have_content "Gemfile" + end + + Then 'I should see files from repository for "8470d70"' do + current_path.should == tree_project_ref_path(@project, "8470d70") + page.should have_content "app" + page.should have_content "History" + page.should have_content "Gemfile" + end + + Given 'I click on "Gemfile" file in repo' do + click_link "Gemfile" + end + + Then 'I should see it content' do + page.should have_content "rubygems.org" + end + + And 'I click link "raw"' do + click_link "raw" + end + + Then 'I should see raw file content' do + page.source.should == ValidCommit::BLOB_FILE + end +end diff --git a/features/steps/project/project_browse_git_repo.rb b/features/steps/project/project_browse_git_repo.rb new file mode 100644 index 00000000000..e966f407738 --- /dev/null +++ b/features/steps/project/project_browse_git_repo.rb @@ -0,0 +1,19 @@ +class ProjectBrowseGitRepo < Spinach::FeatureSteps + include SharedAuthentication + include SharedProject + include SharedPaths + + Given 'I click on "Gemfile" file in repo' do + click_link "Gemfile" + end + + And 'I click blame button' do + click_link "blame" + end + + Then 'I should see git file blame' do + page.should have_content "rubygems.org" + page.should have_content "Dmitriy Zaporozhets" + page.should have_content "bc3735004cb Moving to rails 3.2" + end +end diff --git a/features/steps/project/project_browse_tags.rb b/features/steps/project/project_browse_tags.rb new file mode 100644 index 00000000000..0cbfa0d80aa --- /dev/null +++ b/features/steps/project/project_browse_tags.rb @@ -0,0 +1,10 @@ +class ProjectBrowseTags < Spinach::FeatureSteps + include SharedAuthentication + include SharedProject + include SharedPaths + + Then 'I should see "Shop" all tags list' do + page.should have_content "Tags" + page.should have_content "v1.2.1" + end +end diff --git a/features/steps/project/project_comment_commit.rb b/features/steps/project/project_comment_commit.rb new file mode 100644 index 00000000000..cb8385e1ce5 --- /dev/null +++ b/features/steps/project/project_comment_commit.rb @@ -0,0 +1,6 @@ +class ProjectCommentCommit < Spinach::FeatureSteps + include SharedAuthentication + include SharedProject + include SharedNote + include SharedPaths +end diff --git a/features/steps/project/project_issues.rb b/features/steps/project/project_issues.rb new file mode 100644 index 00000000000..64af24490aa --- /dev/null +++ b/features/steps/project/project_issues.rb @@ -0,0 +1,134 @@ +class ProjectIssues < Spinach::FeatureSteps + include SharedAuthentication + include SharedProject + include SharedNote + include SharedPaths + + Given 'I should see "Release 0.4" in issues' do + page.should have_content "Release 0.4" + end + + And 'I should not see "Release 0.3" in issues' do + page.should_not have_content "Release 0.3" + end + + Given 'I click link "Closed"' do + click_link "Closed" + end + + Then 'I should see "Release 0.3" in issues' do + page.should have_content "Release 0.3" + end + + And 'I should not see "Release 0.4" in issues' do + page.should_not have_content "Release 0.4" + end + + Given 'I click link "All"' do + click_link "All" + end + + Given 'I click link "Release 0.4"' do + click_link "Release 0.4" + end + + Then 'I should see issue "Release 0.4"' do + page.should have_content "Release 0.4" + end + + Given 'I click link "New Issue"' do + click_link "New Issue" + end + + And 'I submit new issue "500 error on profile"' do + fill_in "issue_title", :with => "500 error on profile" + click_button "Submit new issue" + end + + Given 'I click link "500 error on profile"' do + click_link "500 error on profile" + end + + Then 'I should see issue "500 error on profile"' do + issue = Issue.find_by_title("500 error on profile") + page.should have_content issue.title + page.should have_content issue.author_name + page.should have_content issue.project.name + end + + Given 'I fill in issue search with "Release"' do + fill_in 'issue_search', with: "Release" + end + + Given 'I fill in issue search with "Bug"' do + fill_in 'issue_search', with: "Bug" + end + + And 'I fill in issue search with "0.3"' do + fill_in 'issue_search', with: "0.3" + end + + And 'I fill in issue search with "Something"' do + fill_in 'issue_search', with: "Something" + end + + And 'I fill in issue search with ""' do + page.execute_script("$('.issue_search').val('').keyup();"); + fill_in 'issue_search', with: "" + end + + Given 'project "Shop" has milestone "v2.2"' do + project = Project.find_by_name("Shop") + milestone = Factory :milestone, :title => "v2.2", :project => project + + 3.times { Factory :issue, :project => project, :milestone => milestone } + end + + And 'project "Shop" has milestone "v3.0"' do + project = Project.find_by_name("Shop") + milestone = Factory :milestone, :title => "v3.0", :project => project + + 3.times { Factory :issue, :project => project, :milestone => milestone } + end + + When 'I select milestone "v3.0"' do + select "v3.0", from: "milestone_id" + end + + Then 'I should see selected milestone with title "v3.0"' do + issues_milestone_selector = "#issue_milestone_id_chzn/a" + wait_until { page.has_content?("Details") } + page.find(issues_milestone_selector).should have_content("v3.0") + end + + When 'I select first assignee from "Shop" project' do + project = Project.find_by_name "Shop" + first_assignee = project.users.first + select first_assignee.name, from: "assignee_id" + end + + Then 'I should see first assignee from "Shop" as selected assignee' do + issues_assignee_selector = "#issue_assignee_id_chzn/a" + wait_until { page.has_content?("Details") } + project = Project.find_by_name "Shop" + assignee_name = project.users.first.name + page.find(issues_assignee_selector).should have_content(assignee_name) + end + + And 'project "Shop" have "Release 0.4" open issue' do + project = Project.find_by_name("Shop") + Factory.create(:issue, + :title => "Release 0.4", + :project => project, + :author => project.users.first) + end + + And 'project "Shop" have "Release 0.3" closed issue' do + project = Project.find_by_name("Shop") + Factory.create(:issue, + :title => "Release 0.3", + :project => project, + :author => project.users.first, + :closed => true) + end +end diff --git a/features/steps/project/project_labels.rb b/features/steps/project/project_labels.rb new file mode 100644 index 00000000000..1a347bf358f --- /dev/null +++ b/features/steps/project/project_labels.rb @@ -0,0 +1,24 @@ +class ProjectLabels < Spinach::FeatureSteps + include SharedAuthentication + include SharedProject + include SharedPaths + + Then 'I should see label "bug"' do + within ".labels-table" do + page.should have_content "bug" + end + end + + And 'I should see label "feature"' do + within ".labels-table" do + page.should have_content "feature" + end + end + + And 'project "Shop" have issues tags: "bug", "feature"' do + project = Project.find_by_name("Shop") + ['bug', 'feature'].each do |label| + Factory :issue, project: project, label_list: label + end + end +end diff --git a/features/steps/project/project_merge_requests.rb b/features/steps/project/project_merge_requests.rb new file mode 100644 index 00000000000..80e83906c72 --- /dev/null +++ b/features/steps/project/project_merge_requests.rb @@ -0,0 +1,80 @@ +class ProjectMergeRequests < Spinach::FeatureSteps + include SharedAuthentication + include SharedProject + include SharedNote + include SharedPaths + + 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 + + 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 +end diff --git a/features/steps/project/project_milestones.rb b/features/steps/project/project_milestones.rb new file mode 100644 index 00000000000..83ed6859f1b --- /dev/null +++ b/features/steps/project/project_milestones.rb @@ -0,0 +1,39 @@ +class ProjectMilestones < Spinach::FeatureSteps + include SharedAuthentication + include SharedProject + include SharedPaths + + Then 'I should see milestone "v2.2"' do + milestone = @project.milestones.find_by_title("v2.2") + page.should have_content(milestone.title[0..10]) + page.should have_content(milestone.expires_at) + page.should have_content("Browse Issues") + end + + Given 'I click link "v2.2"' do + click_link "v2.2" + end + + Given 'I click link "New Milestone"' do + click_link "New Milestone" + end + + And 'I submit new milestone "v2.3"' do + fill_in "milestone_title", :with => "v2.3" + click_button "Create milestone" + end + + Then 'I should see milestone "v2.3"' do + milestone = @project.milestones.find_by_title("v2.3") + page.should have_content(milestone.title[0..10]) + page.should have_content(milestone.expires_at) + page.should have_content("Browse Issues") + end + + And 'project "Shop" has milestone "v2.2"' do + project = Project.find_by_name("Shop") + milestone = Factory :milestone, :title => "v2.2", :project => project + + 3.times { Factory :issue, :project => project, :milestone => milestone } + end +end diff --git a/features/steps/project/project_network_graph.rb b/features/steps/project/project_network_graph.rb new file mode 100644 index 00000000000..f34a81a408d --- /dev/null +++ b/features/steps/project/project_network_graph.rb @@ -0,0 +1,22 @@ +class ProjectNetworkGraph < Spinach::FeatureSteps + include SharedAuthentication + include SharedProject + + 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 + + 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/project_team_management.rb b/features/steps/project/project_team_management.rb new file mode 100644 index 00000000000..7beca257e36 --- /dev/null +++ b/features/steps/project/project_team_management.rb @@ -0,0 +1,89 @@ +class ProjectTeamManagement < Spinach::FeatureSteps + include SharedAuthentication + include SharedProject + include SharedPaths + + 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 + + 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 + + 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/project_wall.rb b/features/steps/project/project_wall.rb new file mode 100644 index 00000000000..ba9d3533b2c --- /dev/null +++ b/features/steps/project/project_wall.rb @@ -0,0 +1,6 @@ +class ProjectWall < Spinach::FeatureSteps + include SharedAuthentication + include SharedProject + include SharedNote + include SharedPaths +end diff --git a/features/steps/project/project_wiki.rb b/features/steps/project/project_wiki.rb new file mode 100644 index 00000000000..902e9ce158c --- /dev/null +++ b/features/steps/project/project_wiki.rb @@ -0,0 +1,20 @@ +class ProjectWiki < Spinach::FeatureSteps + include SharedAuthentication + include SharedProject + include SharedNote + include SharedPaths + + 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 +end diff --git a/features/steps/project_browse_branches.rb b/features/steps/project_browse_branches.rb deleted file mode 100644 index 9fb2e59ddff..00000000000 --- a/features/steps/project_browse_branches.rb +++ /dev/null @@ -1,44 +0,0 @@ -class ProjectBrowseBranches < Spinach::FeatureSteps - Then 'I should see "Shop" recent branches list' do - page.should have_content "Branches" - page.should have_content "master" - end - - Given 'I click link "All"' do - click_link "All" - end - - Then 'I should see "Shop" all branches list' do - page.should have_content "Branches" - page.should have_content "master" - end - - Given 'I click link "Protected"' do - click_link "Protected" - end - - Then 'I should see "Shop" protected branches list' do - within "table" do - page.should have_content "stable" - page.should_not have_content "master" - 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 'project "Shop" has protected branches' do - project = Project.find_by_name("Shop") - project.protected_branches.create(:name => "stable") - end - - Given 'I visit project branches page' do - visit branches_project_repository_path(@project) - end -end diff --git a/features/steps/project_browse_commits.rb b/features/steps/project_browse_commits.rb deleted file mode 100644 index 71c592a7b57..00000000000 --- a/features/steps/project_browse_commits.rb +++ /dev/null @@ -1,60 +0,0 @@ -class ProjectBrowseCommits < Spinach::FeatureSteps - Then 'I see project commits' do - current_path.should == project_commits_path(@project) - - commit = @project.commit - page.should have_content(@project.name) - page.should have_content(commit.message) - page.should have_content(commit.id.to_s[0..5]) - end - - Given 'I click atom feed link' do - click_link "Feed" - end - - Then 'I see commits atom feed' do - commit = CommitDecorator.decorate(@project.commit) - page.response_headers['Content-Type'].should have_content("application/atom+xml") - page.body.should have_selector("title", :text => "Recent commits to #{@project.name}") - page.body.should have_selector("author email", :text => commit.author_email) - page.body.should have_selector("entry summary", :text => commit.description) - end - - Given 'I click on commit link' do - visit project_commit_path(@project, ValidCommit::ID) - end - - Then 'I see commit info' do - page.should have_content ValidCommit::MESSAGE - page.should have_content "Showing 1 changed file" - end - - Given 'I visit compare refs page' do - visit compare_project_commits_path(@project) - end - - And 'I fill compare fields with refs' do - fill_in "from", :with => "master" - fill_in "to", :with => "stable" - click_button "Compare" - end - - And 'I see compared refs' do - page.should have_content "Commits (27)" - page.should have_content "Compare View" - page.should have_content "Showing 73 changed files" - 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 commits page' do - visit project_commits_path(@project) - end -end diff --git a/features/steps/project_browse_files.rb b/features/steps/project_browse_files.rb deleted file mode 100644 index ad320584567..00000000000 --- a/features/steps/project_browse_files.rb +++ /dev/null @@ -1,51 +0,0 @@ -class ProjectBrowseFiles < Spinach::FeatureSteps - Then 'I should see files from repository' do - page.should have_content "app" - page.should have_content "History" - page.should have_content "Gemfile" - end - - Given 'I visit project source page for "8470d70"' do - visit tree_project_ref_path(@project, "8470d70") - end - - Then 'I should see files from repository for "8470d70"' do - current_path.should == tree_project_ref_path(@project, "8470d70") - page.should have_content "app" - page.should have_content "History" - page.should have_content "Gemfile" - end - - Given 'I click on "Gemfile" file in repo' do - click_link "Gemfile" - end - - Then 'I should see it content' do - page.should have_content "rubygems.org" - end - - Given 'I visit blob file from repo' do - visit tree_project_ref_path(@project, ValidCommit::ID, :path => ValidCommit::BLOB_FILE_PATH) - end - - And 'I click link "raw"' do - click_link "raw" - end - - Then 'I should see raw file content' do - page.source.should == ValidCommit::BLOB_FILE - 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 source page' do - visit tree_project_ref_path(@project, @project.root_ref) - end -end diff --git a/features/steps/project_browse_git_repo.rb b/features/steps/project_browse_git_repo.rb deleted file mode 100644 index 56b33a908a9..00000000000 --- a/features/steps/project_browse_git_repo.rb +++ /dev/null @@ -1,28 +0,0 @@ -class ProjectBrowseGitRepo < Spinach::FeatureSteps - Given 'I click on "Gemfile" file in repo' do - click_link "Gemfile" - end - - And 'I click blame button' do - click_link "blame" - end - - Then 'I should see git file blame' do - page.should have_content "rubygems.org" - page.should have_content "Dmitriy Zaporozhets" - page.should have_content "bc3735004cb Moving to rails 3.2" - 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 source page' do - visit tree_project_ref_path(@project, @project.root_ref) - end -end diff --git a/features/steps/project_browse_tags.rb b/features/steps/project_browse_tags.rb deleted file mode 100644 index c6bea691f04..00000000000 --- a/features/steps/project_browse_tags.rb +++ /dev/null @@ -1,19 +0,0 @@ -class ProjectBrowseTags < Spinach::FeatureSteps - Then 'I should see "Shop" all tags list' do - page.should have_content "Tags" - page.should have_content "v1.2.1" - 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 tags page' do - visit tags_project_repository_path(@project) - end -end diff --git a/features/steps/project_comment_commit.rb b/features/steps/project_comment_commit.rb deleted file mode 100644 index 04e94c7def0..00000000000 --- a/features/steps/project_comment_commit.rb +++ /dev/null @@ -1,23 +0,0 @@ -class ProjectCommentCommit < Spinach::FeatureSteps - Given '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 commit page' do - visit project_commit_path(@project, ValidCommit::ID) - end -end diff --git a/features/steps/project_issues.rb b/features/steps/project_issues.rb deleted file mode 100644 index c3fca0c68b3..00000000000 --- a/features/steps/project_issues.rb +++ /dev/null @@ -1,160 +0,0 @@ -class ProjectIssues < Spinach::FeatureSteps - Given 'I should see "Release 0.4" in issues' do - page.should have_content "Release 0.4" - end - - And 'I should not see "Release 0.3" in issues' do - page.should_not have_content "Release 0.3" - end - - Given 'I click link "Closed"' do - click_link "Closed" - end - - Then 'I should see "Release 0.3" in issues' do - page.should have_content "Release 0.3" - end - - And 'I should not see "Release 0.4" in issues' do - page.should_not have_content "Release 0.4" - end - - Given 'I click link "All"' do - click_link "All" - end - - Given 'I click link "Release 0.4"' do - click_link "Release 0.4" - end - - Then 'I should see issue "Release 0.4"' do - page.should have_content "Release 0.4" - end - - Given 'I click link "New Issue"' do - click_link "New Issue" - end - - And 'I submit new issue "500 error on profile"' do - fill_in "issue_title", :with => "500 error on profile" - click_button "Submit new issue" - end - - Given 'I click link "500 error on profile"' do - click_link "500 error on profile" - end - - Then 'I should see issue "500 error on profile"' do - issue = Issue.find_by_title("500 error on profile") - page.should have_content issue.title - page.should have_content issue.author_name - page.should have_content issue.project.name - end - - Given 'I visit issue page "Release 0.4"' do - issue = Issue.find_by_title("Release 0.4") - visit project_issue_path(issue.project, issue) - 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 fill in issue search with "Release"' do - fill_in 'issue_search', with: "Release" - end - - Given 'I fill in issue search with "Bug"' do - fill_in 'issue_search', with: "Bug" - end - - And 'I fill in issue search with "0.3"' do - fill_in 'issue_search', with: "0.3" - end - - And 'I fill in issue search with "Something"' do - fill_in 'issue_search', with: "Something" - end - - And 'I fill in issue search with ""' do - page.execute_script("$('.issue_search').val('').keyup();"); - fill_in 'issue_search', with: "" - end - - Given 'project "Shop" has milestone "v2.2"' do - project = Project.find_by_name("Shop") - milestone = Factory :milestone, :title => "v2.2", :project => project - - 3.times do - issue = Factory :issue, :project => project, :milestone => milestone - end - end - - And 'project "Shop" has milestone "v3.0"' do - project = Project.find_by_name("Shop") - milestone = Factory :milestone, :title => "v3.0", :project => project - - 3.times do - issue = Factory :issue, :project => project, :milestone => milestone - end - end - - And 'I visit project "Shop" issues page' do - visit project_issues_path(Project.find_by_name("Shop")) - end - - When 'I select milestone "v3.0"' do - select "v3.0", from: "milestone_id" - end - - Then 'I should see selected milestone with title "v3.0"' do - issues_milestone_selector = "#issue_milestone_id_chzn/a" - wait_until { page.has_content?("Details") } - page.find(issues_milestone_selector).should have_content("v3.0") - end - - When 'I select first assignee from "Shop" project' do - project = Project.find_by_name "Shop" - first_assignee = project.users.first - select first_assignee.name, from: "assignee_id" - end - - Then 'I should see first assignee from "Shop" as selected assignee' do - issues_assignee_selector = "#issue_assignee_id_chzn/a" - wait_until { page.has_content?("Details") } - project = Project.find_by_name "Shop" - assignee_name = project.users.first.name - page.find(issues_assignee_selector).should have_content(assignee_name) - 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 "Release 0.4" open issue' do - project = Project.find_by_name("Shop") - Factory.create(:issue, - :title => "Release 0.4", - :project => project, - :author => project.users.first) - end - - And 'project "Shop" have "Release 0.3" closed issue' do - project = Project.find_by_name("Shop") - Factory.create(:issue, - :title => "Release 0.3", - :project => project, - :author => project.users.first, - :closed => true) - end -end diff --git a/features/steps/project_labels.rb b/features/steps/project_labels.rb deleted file mode 100644 index 2e83824fc20..00000000000 --- a/features/steps/project_labels.rb +++ /dev/null @@ -1,33 +0,0 @@ -class ProjectLabels < Spinach::FeatureSteps - Then 'I should see label "bug"' do - within ".labels-table" do - page.should have_content "bug" - end - end - - And 'I should see label "feature"' do - within ".labels-table" do - page.should have_content "feature" - 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 'project "Shop" have issues tags: "bug", "feature"' do - project = Project.find_by_name("Shop") - ['bug', 'feature'].each do |label| - Factory :issue, project: project, label_list: label - end - end - - Given 'I visit project "Shop" labels page' do - visit project_labels_path(Project.find_by_name("Shop")) - end -end diff --git a/features/steps/project_merge_requests.rb b/features/steps/project_merge_requests.rb deleted file mode 100644 index 8515e7e8a1c..00000000000 --- a/features/steps/project_merge_requests.rb +++ /dev/null @@ -1,102 +0,0 @@ -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_milestones.rb b/features/steps/project_milestones.rb deleted file mode 100644 index 97574d1c34d..00000000000 --- a/features/steps/project_milestones.rb +++ /dev/null @@ -1,51 +0,0 @@ -class ProjectMilestones < Spinach::FeatureSteps - Then 'I should see milestone "v2.2"' do - milestone = @project.milestones.find_by_title("v2.2") - page.should have_content(milestone.title[0..10]) - page.should have_content(milestone.expires_at) - page.should have_content("Browse Issues") - end - - Given 'I click link "v2.2"' do - click_link "v2.2" - end - - Given 'I click link "New Milestone"' do - click_link "New Milestone" - end - - And 'I submit new milestone "v2.3"' do - fill_in "milestone_title", :with => "v2.3" - click_button "Create milestone" - end - - Then 'I should see milestone "v2.3"' do - milestone = @project.milestones.find_by_title("v2.3") - page.should have_content(milestone.title[0..10]) - page.should have_content(milestone.expires_at) - page.should have_content("Browse Issues") - 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" has milestone "v2.2"' do - project = Project.find_by_name("Shop") - milestone = Factory :milestone, :title => "v2.2", :project => project - - 3.times do - issue = Factory :issue, :project => project, :milestone => milestone - end - end - - Given 'I visit project "Shop" milestones page' do - @project = Project.find_by_name("Shop") - visit project_milestones_path(@project) - end -end diff --git a/features/steps/project_network_graph.rb b/features/steps/project_network_graph.rb deleted file mode 100644 index d87f3d82951..00000000000 --- a/features/steps/project_network_graph.rb +++ /dev/null @@ -1,28 +0,0 @@ -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 deleted file mode 100644 index 9cee75bd9f8..00000000000 --- a/features/steps/project_team_management.rb +++ /dev/null @@ -1,98 +0,0 @@ -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 deleted file mode 100644 index b94bd0bb1ef..00000000000 --- a/features/steps/project_wall.rb +++ /dev/null @@ -1,24 +0,0 @@ -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 deleted file mode 100644 index 8c8c7c8d78d..00000000000 --- a/features/steps/project_wiki.rb +++ /dev/null @@ -1,37 +0,0 @@ -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 diff --git a/features/steps/shared/authentication.rb b/features/steps/shared/authentication.rb new file mode 100644 index 00000000000..77d9839f5b7 --- /dev/null +++ b/features/steps/shared/authentication.rb @@ -0,0 +1,10 @@ +require Rails.root.join('spec', 'support', 'login_helpers') + +module SharedAuthentication + include Spinach::DSL + include LoginHelpers + + Given 'I sign in as a user' do + login_as :user + end +end diff --git a/features/steps/shared/note.rb b/features/steps/shared/note.rb new file mode 100644 index 00000000000..923e69b6b07 --- /dev/null +++ b/features/steps/shared/note.rb @@ -0,0 +1,21 @@ +module SharedNote + include Spinach::DSL + + Given '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 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 +end diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb new file mode 100644 index 00000000000..05ae88e63e9 --- /dev/null +++ b/features/steps/shared/paths.rb @@ -0,0 +1,112 @@ +module SharedPaths + include Spinach::DSL + + And 'I visit dashboard search page' do + visit search_path + end + + And 'I visit dashboard merge requests page' do + visit dashboard_merge_requests_path + end + + And 'I visit dashboard issues page' do + visit dashboard_issues_path + end + + When 'I visit dashboard page' do + visit dashboard_path + end + + Given 'I visit profile page' do + visit profile_path + end + + Given 'I visit profile password page' do + visit profile_password_path + end + + Given 'I visit profile token page' do + visit profile_token_path + end + + When 'I visit new project page' do + visit new_project_path + end + + And 'I visit project "Shop" page' do + project = Project.find_by_name("Shop") + visit project_path(project) + end + + Given 'I visit project branches page' do + visit branches_project_repository_path(@project) + end + + Given 'I visit compare refs page' do + visit compare_project_commits_path(@project) + end + + Given 'I visit project commits page' do + visit project_commits_path(@project) + end + + Given 'I visit project source page' do + visit tree_project_ref_path(@project, @project.root_ref) + end + + Given 'I visit blob file from repo' do + visit tree_project_ref_path(@project, ValidCommit::ID, :path => ValidCommit::BLOB_FILE_PATH) + end + + Given 'I visit project source page for "8470d70"' do + visit tree_project_ref_path(@project, "8470d70") + end + + Given 'I visit project tags page' do + visit tags_project_repository_path(@project) + end + + Given 'I visit project commit page' do + visit project_commit_path(@project, ValidCommit::ID) + end + + And 'I visit project "Shop" issues page' do + visit project_issues_path(Project.find_by_name("Shop")) + end + + Given 'I visit issue page "Release 0.4"' do + issue = Issue.find_by_title("Release 0.4") + visit project_issue_path(issue.project, issue) + end + + Given 'I visit project "Shop" labels page' do + visit project_labels_path(Project.find_by_name("Shop")) + 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 visit project "Shop" merge requests page' do + visit project_merge_requests_path(Project.find_by_name("Shop")) + end + + Given 'I visit project "Shop" milestones page' do + @project = Project.find_by_name("Shop") + visit project_milestones_path(@project) + end + + Then 'I visit project "Shop" team page' do + visit team_project_path(Project.find_by_name("Shop")) + end + + Then 'I visit project "Shop" wall page' do + project = Project.find_by_name("Shop") + visit wall_project_path(project) + end + + Given 'I visit project wiki page' do + visit project_wiki_path(@project, :index) + end +end diff --git a/features/steps/shared/project.rb b/features/steps/shared/project.rb new file mode 100644 index 00000000000..9b64ca59a3b --- /dev/null +++ b/features/steps/shared/project.rb @@ -0,0 +1,8 @@ +module SharedProject + include Spinach::DSL + + And 'I own project "Shop"' do + @project = Factory :project, :name => "Shop" + @project.add_access(@user, :admin) + end +end diff --git a/features/support/env.rb b/features/support/env.rb index 7bd89801da1..9c6cef07298 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -5,11 +5,12 @@ require 'rspec' require 'database_cleaner' require 'spinach/capybara' -%w(gitolite_stub login_helpers stubbed_repository valid_commit).each do |f| +%w(gitolite_stub stubbed_repository valid_commit).each do |f| require Rails.root.join('spec', 'support', f) end -include LoginHelpers +Dir["#{Rails.root}/features/steps/shared/*.rb"].each {|file| require file} + include GitoliteStub WebMock.allow_net_connect! -- cgit v1.2.1