From decb3abf18314877c7f4fe9241d46936ebe53205 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Mon, 10 Sep 2012 00:42:36 -0700 Subject: [PATCH 01/11] install spinach-rails --- Gemfile | 1 + Gemfile.lock | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/Gemfile b/Gemfile index 6205594a..4e957e92 100644 --- a/Gemfile +++ b/Gemfile @@ -106,6 +106,7 @@ group :development do end group :development, :test do + gem 'spinach-rails' gem "rspec-rails" gem "capybara" gem "capybara-webkit" diff --git a/Gemfile.lock b/Gemfile.lock index 94b16281..317ff694 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -132,6 +132,7 @@ GEM execjs coffee-script-source (1.3.3) colored (1.2) + colorize (0.5.8) crack (0.3.1) cucumber (1.2.1) builder (>= 2.1.2) @@ -172,6 +173,7 @@ GEM thor (>= 0.13.6) gherkin (2.11.0) json (>= 1.4.6) + gherkin-ruby (0.2.1) git (1.2.5) github-markup (0.7.4) gitlab_meta (2.9) @@ -344,6 +346,13 @@ GEM tilt (~> 1.3, >= 1.3.3) six (0.2.0) slop (2.4.4) + spinach (0.5.2) + colorize + gherkin-ruby (~> 0.2.0) + spinach-rails (0.1.8) + capybara (~> 1) + railties (>= 3) + spinach (>= 0.4) sprockets (2.1.3) hike (~> 1.2) rack (~> 1.0) @@ -442,6 +451,7 @@ DEPENDENCIES shoulda-matchers simplecov six + spinach-rails sqlite3 stamp therubyracer From 9f25657ad9b48dab20188bfa51aacbe2e83689e5 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Mon, 10 Sep 2012 00:52:43 -0700 Subject: [PATCH 02/11] modify env file for spinach --- features/support/env.rb | 64 +++++------------------------------------ 1 file changed, 7 insertions(+), 57 deletions(-) diff --git a/features/support/env.rb b/features/support/env.rb index 53578152..aa2f2958 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -1,59 +1,9 @@ -unless ENV['CI'] - require 'simplecov' - SimpleCov.start 'rails' -end +ENV['RAILS_ENV'] = 'test' +require './config/environment' -require 'cucumber/rails' -require 'webmock/cucumber' +require 'rspec' +require 'database_cleaner' -WebMock.allow_net_connect! - -require Rails.root.join 'spec/support/gitolite_stub' -require Rails.root.join 'spec/support/stubbed_repository' -require Rails.root.join 'spec/support/login_helpers' -require Rails.root.join 'spec/support/valid_commit' - -Capybara.default_selector = :css -Capybara.javascript_driver = :webkit - -# By default, any exception happening in your Rails application will bubble up -# to Cucumber so that your scenario will fail. This is a different from how -# your application behaves in the production environment, where an error page will -# be rendered instead. -# -# Sometimes we want to override this default behaviour and allow Rails to rescue -# exceptions and display an error page (just like when the app is running in production). -# Typical scenarios where you want to do this is when you test your error pages. -# There are two ways to allow Rails to rescue exceptions: -# -# 1) Tag your scenario (or feature) with @allow-rescue -# -# 2) Set the value below to true. Beware that doing this globally is not -# recommended as it will mask a lot of errors for you! -# -ActionController::Base.allow_rescue = false - -# Remove/comment out the lines below if your app doesn't have a database. -# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead. -begin - DatabaseCleaner.strategy = :transaction -rescue NameError - raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it." -end - -Cucumber::Rails::Database.javascript_strategy = :truncation - -require 'headless' - -headless = Headless.new -headless.start - -require 'cucumber/rspec/doubles' - -include GitoliteStub - -Before do - stub_gitolite! -end - -World(FactoryGirl::Syntax::Methods) +DatabaseCleaner.strategy = :transaction +Spinach.hooks.before_scenario { DatabaseCleaner.start } +Spinach.hooks.after_scenario { DatabaseCleaner.clean } From bb75052a904c24d1484fa6ec0ad96839effb8ee3 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Mon, 10 Sep 2012 00:53:15 -0700 Subject: [PATCH 03/11] get rid of cucumber step definitions --- features/step_definitions/common_steps.rb | 21 --- features/step_definitions/dashboard_steps.rb | 136 ------------------ .../profile/profile_keys_steps.rb | 34 ----- .../step_definitions/profile/profile_steps.rb | 39 ----- .../project/browse_code_steps.rb | 38 ----- .../project/project_commits_steps.rb | 64 --------- .../project/project_issues_steps.rb | 81 ----------- .../project/project_merge_requests_steps.rb | 38 ----- .../project/project_milestones_steps.rb | 33 ----- .../project/project_team_steps.rb | 55 ------- .../project/project_wiki_steps.rb | 14 -- .../project/projects_steps.rb | 77 ---------- features/step_definitions/visit_steps.rb | 91 ------------ 13 files changed, 721 deletions(-) delete mode 100644 features/step_definitions/common_steps.rb delete mode 100644 features/step_definitions/dashboard_steps.rb delete mode 100644 features/step_definitions/profile/profile_keys_steps.rb delete mode 100644 features/step_definitions/profile/profile_steps.rb delete mode 100644 features/step_definitions/project/browse_code_steps.rb delete mode 100644 features/step_definitions/project/project_commits_steps.rb delete mode 100644 features/step_definitions/project/project_issues_steps.rb delete mode 100644 features/step_definitions/project/project_merge_requests_steps.rb delete mode 100644 features/step_definitions/project/project_milestones_steps.rb delete mode 100644 features/step_definitions/project/project_team_steps.rb delete mode 100644 features/step_definitions/project/project_wiki_steps.rb delete mode 100644 features/step_definitions/project/projects_steps.rb delete mode 100644 features/step_definitions/visit_steps.rb diff --git a/features/step_definitions/common_steps.rb b/features/step_definitions/common_steps.rb deleted file mode 100644 index e9023f92..00000000 --- a/features/step_definitions/common_steps.rb +++ /dev/null @@ -1,21 +0,0 @@ -include LoginHelpers - -Given /^I signin as a user$/ do - login_as :user -end - -When /^I click link "(.*?)"$/ do |link| - click_link link -end - -When /^I click button "(.*?)"$/ do |button| - click_button button -end - -When /^I fill in "(.*?)" with "(.*?)"$/ do |field, value| - fill_in field, :with => value -end - -Given /^show me page$/ do - save_and_open_page -end diff --git a/features/step_definitions/dashboard_steps.rb b/features/step_definitions/dashboard_steps.rb deleted file mode 100644 index 3ddc68e9..00000000 --- a/features/step_definitions/dashboard_steps.rb +++ /dev/null @@ -1,136 +0,0 @@ -Then /^I should see "(.*?)" link$/ do |arg1| - page.should have_link(arg1) -end - -Then /^I should see "(.*?)" project link$/ do |arg1| - page.should have_link(arg1) -end - -Then /^I should see project "(.*?)" activity feed$/ do |arg1| - project = Project.find_by_name(arg1) - page.should have_content "#{@user.name} pushed new branch new_design at #{project.name}" -end - -Given /^project "(.*?)" has push event$/ do |arg1| - @project = Project.find_by_name(arg1) - - 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 - -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 - -Then /^I click "(.*?)" link$/ do |arg1| - click_link arg1 #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 /^I visit dashboard search page$/ do - visit search_path -end - -Given /^I search for "(.*?)"$/ do |arg1| - fill_in "dashboard_search", :with => arg1 - click_button "Search" -end - -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 - -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 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 - -Given /^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 - -Given /^user with name "(.*?)" joined project "(.*?)"$/ do |user_name, project_name| - user = Factory.create(:user, {name: user_name}) - project = Project.find_by_name project_name - Event.create( - project: project, - author_id: user.id, - action: Event::Joined - ) -end - -Given /^user with name "(.*?)" left project "(.*?)"$/ do |user_name, project_name| - user = User.find_by_name user_name - project = Project.find_by_name project_name - Event.create( - project: project, - author_id: user.id, - action: Event::Left - ) -end - -Then /^I should see "(.*?)" event$/ do |event_text| - page.should have_content(event_text) -end - diff --git a/features/step_definitions/profile/profile_keys_steps.rb b/features/step_definitions/profile/profile_keys_steps.rb deleted file mode 100644 index 25926c53..00000000 --- a/features/step_definitions/profile/profile_keys_steps.rb +++ /dev/null @@ -1,34 +0,0 @@ -Given /^I visit profile keys page$/ do - visit keys_path -end - -Then /^I should see my ssh keys$/ do - @user.keys.each do |key| - page.should have_content(key.title) - end -end - -Given /^I have ssh keys:$/ do |table| - table.hashes.each do |row| - Factory :key, :user => @user, :title => row[:title], :key => "jfKLJDFKSFJSHFJ#{row[:title]}" - end -end - -Given /^I submit new ssh key "(.*?)"$/ do |arg1| - fill_in "key_title", :with => arg1 - fill_in "key_key", :with => "ssh-rsa publickey234=" - click_button "Save" -end - -Then /^I should see new ssh key "(.*?)"$/ do |arg1| - key = Key.find_by_title(arg1) - page.should have_content(key.title) - page.should have_content(key.key) - current_path.should == key_path(key) -end - -Then /^I should not see "(.*?)" ssh key$/ do |arg1| - within "#keys-table" do - page.should_not have_content(arg1) - end -end diff --git a/features/step_definitions/profile/profile_steps.rb b/features/step_definitions/profile/profile_steps.rb deleted file mode 100644 index 525d43f5..00000000 --- a/features/step_definitions/profile/profile_steps.rb +++ /dev/null @@ -1,39 +0,0 @@ -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 password$/ do - fill_in "user_password", :with => "222333" - fill_in "user_password_confirmation", :with => "222333" - click_button "Save" -end - -Then /^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 - -Then /^I should see new token$/ do - find("#token").value.should_not == @old_token - find("#token").value.should == @user.reload.private_token -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 - -Then /^I should see new contact info$/ do - @user.skype.should == 'testskype' - @user.linkedin.should == 'testlinkedin' - @user.twitter.should == 'testtwitter' -end diff --git a/features/step_definitions/project/browse_code_steps.rb b/features/step_definitions/project/browse_code_steps.rb deleted file mode 100644 index d2ed9a0a..00000000 --- a/features/step_definitions/project/browse_code_steps.rb +++ /dev/null @@ -1,38 +0,0 @@ -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 "(.*?)"$/ do |arg1| - current_path.should == tree_project_ref_path(@project, arg1) - page.should have_content("app") - page.should have_content("History") - page.should have_content("Gemfile") -end - -Given /^I click on file from repo$/ do - click_link "Gemfile" -end - -Then /^I should see it content$/ do - page.should have_content("rubygems.org") -end - -Given /^I click on raw button$/ do - click_link "raw" -end - -Then /^I should see raw file content$/ do - page.source.should == ValidCommit::BLOB_FILE -end - -Given /^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 diff --git a/features/step_definitions/project/project_commits_steps.rb b/features/step_definitions/project/project_commits_steps.rb deleted file mode 100644 index 7f20ade4..00000000 --- a/features/step_definitions/project/project_commits_steps.rb +++ /dev/null @@ -1,64 +0,0 @@ -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 - -Then /^I see commit info$/ do - page.should have_content ValidCommit::MESSAGE - page.should have_content "Showing 1 changed file" -end - -Given /^I fill compare fields with refs$/ do - fill_in "from", :with => "master" - fill_in "to", :with => "stable" - click_button "Compare" -end - -Given /^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 - -Then /^I should see "(.*?)" recent branches list$/ do |arg1| - page.should have_content("Branches") - page.should have_content("master") -end - -Then /^I should see "(.*?)" all branches list$/ do |arg1| - page.should have_content("Branches") - page.should have_content("master") -end - -Then /^I should see "(.*?)" all tags list$/ do |arg1| - page.should have_content("Tags") - page.should have_content("v1.2.1") -end - -Then /^I should see "(.*?)" protected branches list$/ do |arg1| - within "table" do - page.should have_content "stable" - page.should_not have_content "master" - end -end - -Given /^project "(.*?)" has protected branches$/ do |arg1| - project = Project.find_by_name(arg1) - project.protected_branches.create(:name => "stable") -end diff --git a/features/step_definitions/project/project_issues_steps.rb b/features/step_definitions/project/project_issues_steps.rb deleted file mode 100644 index d78da53c..00000000 --- a/features/step_definitions/project/project_issues_steps.rb +++ /dev/null @@ -1,81 +0,0 @@ -Given /^project "(.*?)" have "(.*?)" open issue$/ do |arg1, arg2| - project = Project.find_by_name(arg1) - Factory.create(:issue, :title => arg2, :project => project, :author => project.users.first) -end - -Given /^project "(.*?)" have "(.*?)" closed issue$/ do |arg1, arg2| - project = Project.find_by_name(arg1) - Factory.create(:issue, :title => arg2, :project => project, :author => project.users.first, :closed => true) -end - -Given /^I should see "(.*?)" in issues$/ do |arg1| - page.should have_content arg1 -end - -Given /^I should not see "(.*?)" in issues$/ do |arg1| - page.should_not have_content arg1 -end - -Then /^I should see issue "(.*?)"$/ do |arg1| - issue = Issue.find_by_title(arg1) - page.should have_content issue.title - page.should have_content issue.author_name - page.should have_content issue.project.name -end - -Given /^I submit new issue "(.*?)"$/ do |arg1| - fill_in "issue_title", with: arg1 - click_button "Submit new issue" -end - -Given /^project "(.*?)" have issues tags:$/ do |arg1, table| - project = Project.find_by_name(arg1) - table.hashes.each do |hash| - Factory :issue, - project: project, - label_list: [hash[:name]] - end -end - -Given /^I visit project "(.*?)" labels page$/ do |arg1| - visit project_labels_path(Project.find_by_name(arg1)) -end - -Then /^I should see label "(.*?)"$/ do |arg1| - within ".labels-table" do - page.should have_content arg1 - end -end - -Given /^I fill in issue search with "(.*?)"$/ do |arg1| - # Because fill_in, with: "" triggers nothing - # we need to trigger a keyup event - if arg1 == '' - page.execute_script("$('.issue_search').val('').keyup();"); - end - fill_in 'issue_search', with: arg1 -end - -When /^I select milestone "(.*?)"$/ do |milestone_title| - select milestone_title, from: "milestone_id" -end - -Then /^I should see selected milestone with title "(.*?)"$/ do |milestone_title| - issues_milestone_selector = "#issue_milestone_id_chzn/a" - wait_until{ page.has_content?("Details") } - page.find(issues_milestone_selector).should have_content(milestone_title) -end - -When /^I select first assignee from "(.*?)" project$/ do |project_name| - project = Project.find_by_name project_name - first_assignee = project.users.first - select first_assignee.name, from: "assignee_id" -end - -Then /^I should see first assignee from "(.*?)" as selected assignee$/ do |project_name| - issues_assignee_selector = "#issue_assignee_id_chzn/a" - wait_until{ page.has_content?("Details") } - project = Project.find_by_name project_name - assignee_name = project.users.first.name - page.find(issues_assignee_selector).should have_content(assignee_name) -end diff --git a/features/step_definitions/project/project_merge_requests_steps.rb b/features/step_definitions/project/project_merge_requests_steps.rb deleted file mode 100644 index fddb18ad..00000000 --- a/features/step_definitions/project/project_merge_requests_steps.rb +++ /dev/null @@ -1,38 +0,0 @@ -Given /^project "(.*?)" have "(.*?)" open merge request$/ do |arg1, arg2| - project = Project.find_by_name(arg1) - Factory.create(:merge_request, :title => arg2, :project => project, :author => project.users.first) -end - -Given /^project "(.*?)" have "(.*?)" closed merge request$/ do |arg1, arg2| - project = Project.find_by_name(arg1) - Factory.create(:merge_request, :title => arg2, :project => project, :author => project.users.first, :closed => true) -end - -Then /^I should see "(.*?)" in merge requests$/ do |arg1| - page.should have_content arg1 -end - -Then /^I should not see "(.*?)" in merge requests$/ do |arg1| - page.should_not have_content arg1 -end - -Then /^I should see merge request "(.*?)"$/ do |arg1| - merge_request = MergeRequest.find_by_title(arg1) - page.should have_content(merge_request.title[0..10]) - page.should have_content(merge_request.target_branch) - page.should have_content(merge_request.source_branch) -end - -Given /^I submit new merge request "(.*?)"$/ do |arg1| - fill_in "merge_request_title", :with => arg1 - select "master", :from => "merge_request_source_branch" - select "stable", :from => "merge_request_target_branch" - click_button "Save" -end - -Then /^I should see closed merge request "(.*?)"$/ do |arg1| - mr = MergeRequest.find_by_title(arg1) - mr.closed.should be_true - page.should have_content "Closed by" -end - diff --git a/features/step_definitions/project/project_milestones_steps.rb b/features/step_definitions/project/project_milestones_steps.rb deleted file mode 100644 index 936c52df..00000000 --- a/features/step_definitions/project/project_milestones_steps.rb +++ /dev/null @@ -1,33 +0,0 @@ -Given /^project "(.*?)" has milestone "(.*?)"$/ do |arg1, arg2| - project = Project.find_by_name(arg1) - - milestone = Factory :milestone, - :title => arg2, - :project => project - - 3.times do |i| - issue = Factory :issue, - :project => project, - :milestone => milestone - end -end - -Then /^I should see active milestones$/ do - milestone = @project.milestones.first - page.should have_content(milestone.title[0..10]) - page.should have_content(milestone.expires_at) - page.should have_content("Browse Issues") -end - -Then /^I should see milestone "(.*?)"$/ do |arg1| - milestone = @project.milestones.find_by_title(arg1) - page.should have_content(milestone.title[0..10]) - page.should have_content(milestone.expires_at) - page.should have_content("Browse Issues") -end - -Given /^I submit new milestone "(.*?)"$/ do |arg1| - fill_in "milestone_title", :with => arg1 - click_button "Create milestone" -end - diff --git a/features/step_definitions/project/project_team_steps.rb b/features/step_definitions/project/project_team_steps.rb deleted file mode 100644 index 91885e46..00000000 --- a/features/step_definitions/project/project_team_steps.rb +++ /dev/null @@ -1,55 +0,0 @@ -Given /^gitlab user "(.*?)"$/ do |arg1| - Factory :user, :name => arg1 -end - -Given /^"(.*?)" is "(.*?)" developer$/ do |arg1, arg2| - user = User.find_by_name(arg1) - project = Project.find_by_name(arg2) - project.add_access(user, :write) -end - -Then /^I should be able to see myself in team$/ do - page.should have_content(@user.name) - page.should have_content(@user.email) -end - -Then /^I should see "(.*?)" in team list$/ do |arg1| - user = User.find_by_name(arg1) - page.should have_content(user.name) - page.should have_content(user.email) -end - -Given /^I select "(.*?)" as "(.*?)"$/ do |arg1, arg2| - user = User.find_by_name(arg1) - within "#new_team_member" do - select user.name, :from => "user_ids" - select arg2, :from => "project_access" - end - click_button "Save" -end - -Then /^I should see "(.*?)" in team list as "(.*?)"$/ do |arg1, arg2| - user = User.find_by_name(arg1) - role_id = find(".user_#{user.id} #team_member_project_access").value - role_id.should == UsersProject.access_roles[arg2].to_s -end - -Given /^I change "(.*?)" role to "(.*?)"$/ do |arg1, arg2| - user = User.find_by_name(arg1) - within ".user_#{user.id}" do - select arg2, :from => "team_member_project_access" - end -end - -Then /^I should see "(.*?)" team profile$/ do |arg1| - user = User.find_by_name(arg1) - page.should have_content(user.name) - page.should have_content(user.email) - page.should have_content("To team list") -end - -Then /^I should not see "(.*?)" in team list$/ do |arg1| - user = User.find_by_name(arg1) - page.should_not have_content(user.name) - page.should_not have_content(user.email) -end diff --git a/features/step_definitions/project/project_wiki_steps.rb b/features/step_definitions/project/project_wiki_steps.rb deleted file mode 100644 index 31fc050a..00000000 --- a/features/step_definitions/project/project_wiki_steps.rb +++ /dev/null @@ -1,14 +0,0 @@ -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 diff --git a/features/step_definitions/project/projects_steps.rb b/features/step_definitions/project/projects_steps.rb deleted file mode 100644 index d22b805f..00000000 --- a/features/step_definitions/project/projects_steps.rb +++ /dev/null @@ -1,77 +0,0 @@ -When /^I visit new project page$/ do - visit new_project_path -end - -When /^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 - -Then /^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 - -Given /^I own project "(.*?)"$/ do |arg1| - @project = Factory :project, :name => arg1 - @project.add_access(@user, :admin) -end - -Given /^I visit project "(.*?)" wall page$/ do |arg1| - project = Project.find_by_name(arg1) - visit wall_project_path(project) -end - -Then /^I should see project wall note "(.*?)"$/ do |arg1| - page.should have_content arg1 -end - -Given /^project "(.*?)" has comment "(.*?)"$/ do |arg1, arg2| - project = Project.find_by_name(arg1) - project.notes.create(:note => arg1, :author => project.users.first) -end - -Given /^I write new comment "(.*?)"$/ do |arg1| - fill_in "note_note", :with => arg1 - click_button "Add Comment" -end - -Given /^I visit project "(.*?)" page$/ do |arg1| - project = Project.find_by_name(arg1) - visit project_path(project) -end - -Given /^I visit project "(.*?)" network page$/ do |arg1| - project = Project.find_by_name(arg1) - - # 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 - -Given /^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 leave a comment like "(.*?)"$/ do |arg1| - fill_in "note_note", :with => arg1 - click_button "Add Comment" -end - -Then /^I should see comment "(.*?)"$/ do |arg1| - page.should have_content(arg1) -end diff --git a/features/step_definitions/visit_steps.rb b/features/step_definitions/visit_steps.rb deleted file mode 100644 index 35fc6d44..00000000 --- a/features/step_definitions/visit_steps.rb +++ /dev/null @@ -1,91 +0,0 @@ -Given /^I visit project "(.*?)" issues page$/ do |arg1| - visit project_issues_path(Project.find_by_name(arg1)) -end - -Given /^I visit issue page "(.*?)"$/ do |arg1| - issue = Issue.find_by_title(arg1) - visit project_issue_path(issue.project, issue) -end - -Given /^I visit project "(.*?)" merge requests page$/ do |arg1| - visit project_merge_requests_path(Project.find_by_name(arg1)) -end - -Given /^I visit merge request page "(.*?)"$/ do |arg1| - mr = MergeRequest.find_by_title(arg1) - visit project_merge_request_path(mr.project, mr) -end - -Given /^I visit project "(.*?)" milestones page$/ do |arg1| - @project = Project.find_by_name(arg1) - visit project_milestones_path(@project) -end - -Given /^I visit project commits page$/ do - visit project_commits_path(@project) -end - -Given /^I visit compare refs page$/ do - visit compare_project_commits_path(@project) -end - -Given /^I visit project branches page$/ do - visit branches_project_repository_path(@project) -end - -Given /^I visit project commit page$/ do - visit project_commit_path(@project, ValidCommit::ID) -end - -Given /^I visit project tags page$/ do - visit tags_project_repository_path(@project) -end - -Given /^I click on commit link$/ do - visit project_commit_path(@project, ValidCommit::ID) -end - -Given /^I visit project source page$/ do - visit tree_project_ref_path(@project, @project.root_ref) -end - -Given /^I visit project source page for "(.*?)"$/ do |arg1| - visit tree_project_ref_path(@project, arg1) -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 "(.*?)" team page$/ do |arg1| - visit team_project_path(Project.find_by_name(arg1)) -end - -Given /^I visit project wiki page$/ do - visit project_wiki_path(@project, :index) -end - -Given /^I visit profile page$/ do - visit profile_path -end - -Given /^I visit profile token page$/ do - visit profile_token_path -end - -Given /^I visit profile password page$/ do - visit profile_password_path -end - -Given /^I visit dashboard page$/ do - visit dashboard_path -end - -Given /^I visit dashboard issues page$/ do - visit dashboard_issues_path -end - -Given /^I visit dashboard merge requests page$/ do - visit dashboard_merge_requests_path -end - From d74f54736b8aabb3885648c44d7e253209b8e9e1 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Mon, 10 Sep 2012 01:51:02 -0700 Subject: [PATCH 04/11] rewrite dashboard feature steps using spinach --- features/dashboard/dashboard.feature | 7 +- features/dashboard/issues.feature | 6 +- features/dashboard/merge_requests.feature | 8 +- features/dashboard/search.feature | 10 +-- features/steps/dashboard.rb | 97 ++++++++++++++++++++++ features/steps/dashboard_issues.rb | 32 +++++++ features/steps/dashboard_merge_requests.rb | 33 ++++++++ features/steps/dashboard_search.rb | 23 +++++ features/support/env.rb | 6 ++ 9 files changed, 205 insertions(+), 17 deletions(-) create mode 100644 features/steps/dashboard.rb create mode 100644 features/steps/dashboard_issues.rb create mode 100644 features/steps/dashboard_merge_requests.rb create mode 100644 features/steps/dashboard_search.rb diff --git a/features/dashboard/dashboard.feature b/features/dashboard/dashboard.feature index 98bb4980..9756bc7f 100644 --- a/features/dashboard/dashboard.feature +++ b/features/dashboard/dashboard.feature @@ -1,9 +1,9 @@ Feature: Dashboard - Background: - Given I signin as a user + Background: + Given I sign in as a user And I own project "Shop" And project "Shop" has push event - And I visit dashboard page + And I visit dashboard page Scenario: I should see projects list Then I should see "New Project" link @@ -25,4 +25,3 @@ Feature: Dashboard And user with name "John Doe" left project "Shop" When I visit dashboard page Then I should see "John Doe left project Shop" event - diff --git a/features/dashboard/issues.feature b/features/dashboard/issues.feature index c3361bb3..895b89aa 100644 --- a/features/dashboard/issues.feature +++ b/features/dashboard/issues.feature @@ -1,8 +1,8 @@ Feature: Dashboard Issues - Background: - Given I signin as a user + Background: + Given I sign in as a user And I have assigned issues - And I visit dashboard issues page + And I visit dashboard issues page Scenario: I should see issues list Then I should see issues assigned to me diff --git a/features/dashboard/merge_requests.feature b/features/dashboard/merge_requests.feature index 90b8749c..cad65b0d 100644 --- a/features/dashboard/merge_requests.feature +++ b/features/dashboard/merge_requests.feature @@ -1,8 +1,8 @@ -Feature: Dashboard MR - Background: - Given I signin as a user +Feature: Dashboard Merge Requests + Background: + Given I sign in as a user And I have authored merge requests - And I visit dashboard merge requests page + And I visit dashboard merge requests page Scenario: I should see projects list Then I should see my merge requests diff --git a/features/dashboard/search.feature b/features/dashboard/search.feature index f053fe86..91d870f4 100644 --- a/features/dashboard/search.feature +++ b/features/dashboard/search.feature @@ -1,11 +1,9 @@ Feature: Dashboard Search - Background: - Given I signin as a user + Background: + Given I sign in as a user And I own project "Shop" - And I visit dashboard search page + And I visit dashboard search page - Scenario: I should see project i'm looking for + Scenario: I should see project I am looking for Given I search for "Sho" Then I should see "Shop" project link - - diff --git a/features/steps/dashboard.rb b/features/steps/dashboard.rb new file mode 100644 index 00000000..e69686b3 --- /dev/null +++ b/features/steps/dashboard.rb @@ -0,0 +1,97 @@ +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_issues.rb b/features/steps/dashboard_issues.rb new file mode 100644 index 00000000..8704d2ef --- /dev/null +++ b/features/steps/dashboard_issues.rb @@ -0,0 +1,32 @@ +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 new file mode 100644 index 00000000..3e057ef9 --- /dev/null +++ b/features/steps/dashboard_merge_requests.rb @@ -0,0 +1,33 @@ +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 new file mode 100644 index 00000000..122774fc --- /dev/null +++ b/features/steps/dashboard_search.rb @@ -0,0 +1,23 @@ +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/support/env.rb b/features/support/env.rb index aa2f2958..2900e1cb 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -4,6 +4,12 @@ require './config/environment' require 'rspec' require 'database_cleaner' +%w(login_helpers stubbed_repository).each do |f| + require Rails.root.join('spec', 'support', f) +end + +include LoginHelpers + DatabaseCleaner.strategy = :transaction Spinach.hooks.before_scenario { DatabaseCleaner.start } Spinach.hooks.after_scenario { DatabaseCleaner.clean } From 7aeb92b8e4bb279346d9dcec7bbca1725cec8eb1 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Mon, 10 Sep 2012 02:40:51 -0700 Subject: [PATCH 05/11] rewrite profile feature steps using spinach --- features/profile/profile.feature | 4 +-- features/profile/ssh_keys.feature | 13 +++---- features/steps/profile.rb | 57 ++++++++++++++++++++++++++++++ features/steps/profile_ssh_keys.rb | 50 ++++++++++++++++++++++++++ 4 files changed, 114 insertions(+), 10 deletions(-) create mode 100644 features/steps/profile.rb create mode 100644 features/steps/profile_ssh_keys.rb diff --git a/features/profile/profile.feature b/features/profile/profile.feature index afda4b55..f4b2f198 100644 --- a/features/profile/profile.feature +++ b/features/profile/profile.feature @@ -1,6 +1,6 @@ Feature: Profile - Background: - Given I signin as a user + Background: + Given I sign in as a user Scenario: I look at my profile Given I visit profile page diff --git a/features/profile/ssh_keys.feature b/features/profile/ssh_keys.feature index c81503ed..018d124e 100644 --- a/features/profile/ssh_keys.feature +++ b/features/profile/ssh_keys.feature @@ -1,13 +1,10 @@ -Feature: SSH Keys - Background: - Given I signin as a user - And I have ssh keys: - | title | - | ssh-rsa Work | - | ssh-rsa Home | +Feature: Profile SSH Keys + Background: + Given I sign in as a user + And I have ssh key "ssh-rsa Work" And I visit profile keys page - Scenario: I should see SSH keys + Scenario: I should see ssh keys Then I should see my ssh keys Scenario: Add new ssh key diff --git a/features/steps/profile.rb b/features/steps/profile.rb new file mode 100644 index 00000000..c7e6be3f --- /dev/null +++ b/features/steps/profile.rb @@ -0,0 +1,57 @@ +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_ssh_keys.rb b/features/steps/profile_ssh_keys.rb new file mode 100644 index 00000000..9360f66f --- /dev/null +++ b/features/steps/profile_ssh_keys.rb @@ -0,0 +1,50 @@ +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 From 080bd12e167dceb3274bb488b7be787379d126b4 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Mon, 10 Sep 2012 04:27:11 -0700 Subject: [PATCH 06/11] rewrite project commits features using spinach --- .../commits/branches.feature | 15 +++-- .../commits/commit_comments.feature | 6 +- .../commits/commits.feature | 9 ++- .../commits/tags.feature | 9 +-- .../create_project.feature | 0 .../{projects => project}/deploy_keys.feature | 0 .../issues/issues.feature | 0 .../issues/labels.feature | 0 .../issues/milestones.feature | 0 .../merge_requests.feature | 0 .../{projects => project}/network.feature | 0 .../{projects => project}/project.feature | 0 .../{projects => project}/snippets.feature | 0 .../source/browse_files.feature | 0 .../source/git_blame.feature | 0 .../team_management.feature | 0 features/{projects => project}/wall.feature | 0 .../{projects => project}/web_hooks.feature | 0 features/{projects => project}/wiki.feature | 0 features/steps/project_browse_branches.rb | 44 ++++++++++++++ features/steps/project_browse_commits.rb | 60 +++++++++++++++++++ features/steps/project_browse_tags.rb | 19 ++++++ features/steps/project_comment_commit.rb | 23 +++++++ features/support/env.rb | 13 +++- 24 files changed, 178 insertions(+), 20 deletions(-) rename features/{projects => project}/commits/branches.feature (66%) rename features/{projects => project}/commits/commit_comments.feature (72%) rename features/{projects => project}/commits/commits.feature (82%) rename features/{projects => project}/commits/tags.feature (53%) rename features/{projects => project}/create_project.feature (100%) rename features/{projects => project}/deploy_keys.feature (100%) rename features/{projects => project}/issues/issues.feature (100%) rename features/{projects => project}/issues/labels.feature (100%) rename features/{projects => project}/issues/milestones.feature (100%) rename features/{projects => project}/merge_requests.feature (100%) rename features/{projects => project}/network.feature (100%) rename features/{projects => project}/project.feature (100%) rename features/{projects => project}/snippets.feature (100%) rename features/{projects => project}/source/browse_files.feature (100%) rename features/{projects => project}/source/git_blame.feature (100%) rename features/{projects => project}/team_management.feature (100%) rename features/{projects => project}/wall.feature (100%) rename features/{projects => project}/web_hooks.feature (100%) rename features/{projects => project}/wiki.feature (100%) create mode 100644 features/steps/project_browse_branches.rb create mode 100644 features/steps/project_browse_commits.rb create mode 100644 features/steps/project_browse_tags.rb create mode 100644 features/steps/project_comment_commit.rb diff --git a/features/projects/commits/branches.feature b/features/project/commits/branches.feature similarity index 66% rename from features/projects/commits/branches.feature rename to features/project/commits/branches.feature index 74575c51..4fa4dc26 100644 --- a/features/projects/commits/branches.feature +++ b/features/project/commits/branches.feature @@ -1,6 +1,6 @@ -Feature: Browse branches - Background: - Given I signin as a user +Feature: Project Browse branches + Background: + Given I sign in as a user And I own project "Shop" And project "Shop" has protected branches Given I visit project branches page @@ -16,8 +16,11 @@ Feature: Browse branches Given I click link "Protected" Then I should see "Shop" protected branches list - Scenario: I can download project by branch + # @wip + # Scenario: I can download project by branch - Scenario: I can view protected branches + # @wip + # Scenario: I can view protected branches - Scenario: I can manage protected branches + # @wip + # Scenario: I can manage protected branches diff --git a/features/projects/commits/commit_comments.feature b/features/project/commits/commit_comments.feature similarity index 72% rename from features/projects/commits/commit_comments.feature rename to features/project/commits/commit_comments.feature index 9bd56d29..5acf541a 100644 --- a/features/projects/commits/commit_comments.feature +++ b/features/project/commits/commit_comments.feature @@ -1,6 +1,6 @@ -Feature: Comment commit - Background: - Given I signin as a user +Feature: Project Comment commit + Background: + Given I sign in as a user And I own project "Shop" Given I visit project commit page diff --git a/features/projects/commits/commits.feature b/features/project/commits/commits.feature similarity index 82% rename from features/projects/commits/commits.feature rename to features/project/commits/commits.feature index 69d39d78..53de6e6a 100644 --- a/features/projects/commits/commits.feature +++ b/features/project/commits/commits.feature @@ -1,6 +1,6 @@ -Feature: Browse commits - Background: - Given I signin as a user +Feature: Project Browse commits + Background: + Given I sign in as a user And I own project "Shop" Given I visit project commits page @@ -18,5 +18,4 @@ Feature: Browse commits Scenario: I compare refs Given I visit compare refs page And I fill compare fields with refs - And I see compared refs - + And I see compared refs diff --git a/features/projects/commits/tags.feature b/features/project/commits/tags.feature similarity index 53% rename from features/projects/commits/tags.feature rename to features/project/commits/tags.feature index f7899fc3..1ac0f8bf 100644 --- a/features/projects/commits/tags.feature +++ b/features/project/commits/tags.feature @@ -1,10 +1,11 @@ -Feature: Browse tags - Background: - Given I signin as a user +Feature: Project Browse tags + Background: + Given I sign in as a user And I own project "Shop" Given I visit project tags page Scenario: I can see all git tags Then I should see "Shop" all tags list - Scenario: I can download project by tag + # @wip + # Scenario: I can download project by tag diff --git a/features/projects/create_project.feature b/features/project/create_project.feature similarity index 100% rename from features/projects/create_project.feature rename to features/project/create_project.feature diff --git a/features/projects/deploy_keys.feature b/features/project/deploy_keys.feature similarity index 100% rename from features/projects/deploy_keys.feature rename to features/project/deploy_keys.feature diff --git a/features/projects/issues/issues.feature b/features/project/issues/issues.feature similarity index 100% rename from features/projects/issues/issues.feature rename to features/project/issues/issues.feature diff --git a/features/projects/issues/labels.feature b/features/project/issues/labels.feature similarity index 100% rename from features/projects/issues/labels.feature rename to features/project/issues/labels.feature diff --git a/features/projects/issues/milestones.feature b/features/project/issues/milestones.feature similarity index 100% rename from features/projects/issues/milestones.feature rename to features/project/issues/milestones.feature diff --git a/features/projects/merge_requests.feature b/features/project/merge_requests.feature similarity index 100% rename from features/projects/merge_requests.feature rename to features/project/merge_requests.feature diff --git a/features/projects/network.feature b/features/project/network.feature similarity index 100% rename from features/projects/network.feature rename to features/project/network.feature diff --git a/features/projects/project.feature b/features/project/project.feature similarity index 100% rename from features/projects/project.feature rename to features/project/project.feature diff --git a/features/projects/snippets.feature b/features/project/snippets.feature similarity index 100% rename from features/projects/snippets.feature rename to features/project/snippets.feature diff --git a/features/projects/source/browse_files.feature b/features/project/source/browse_files.feature similarity index 100% rename from features/projects/source/browse_files.feature rename to features/project/source/browse_files.feature diff --git a/features/projects/source/git_blame.feature b/features/project/source/git_blame.feature similarity index 100% rename from features/projects/source/git_blame.feature rename to features/project/source/git_blame.feature diff --git a/features/projects/team_management.feature b/features/project/team_management.feature similarity index 100% rename from features/projects/team_management.feature rename to features/project/team_management.feature diff --git a/features/projects/wall.feature b/features/project/wall.feature similarity index 100% rename from features/projects/wall.feature rename to features/project/wall.feature diff --git a/features/projects/web_hooks.feature b/features/project/web_hooks.feature similarity index 100% rename from features/projects/web_hooks.feature rename to features/project/web_hooks.feature diff --git a/features/projects/wiki.feature b/features/project/wiki.feature similarity index 100% rename from features/projects/wiki.feature rename to features/project/wiki.feature diff --git a/features/steps/project_browse_branches.rb b/features/steps/project_browse_branches.rb new file mode 100644 index 00000000..9fb2e59d --- /dev/null +++ b/features/steps/project_browse_branches.rb @@ -0,0 +1,44 @@ +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 new file mode 100644 index 00000000..71c592a7 --- /dev/null +++ b/features/steps/project_browse_commits.rb @@ -0,0 +1,60 @@ +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_tags.rb b/features/steps/project_browse_tags.rb new file mode 100644 index 00000000..c6bea691 --- /dev/null +++ b/features/steps/project_browse_tags.rb @@ -0,0 +1,19 @@ +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 new file mode 100644 index 00000000..04e94c7d --- /dev/null +++ b/features/steps/project_comment_commit.rb @@ -0,0 +1,23 @@ +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/support/env.rb b/features/support/env.rb index 2900e1cb..38d828a2 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -4,12 +4,21 @@ require './config/environment' require 'rspec' require 'database_cleaner' -%w(login_helpers stubbed_repository).each do |f| +%w(gitolite_stub login_helpers stubbed_repository valid_commit).each do |f| require Rails.root.join('spec', 'support', f) end include LoginHelpers +include GitoliteStub -DatabaseCleaner.strategy = :transaction +WebMock.allow_net_connect! + +DatabaseCleaner.strategy = :truncation Spinach.hooks.before_scenario { DatabaseCleaner.start } Spinach.hooks.after_scenario { DatabaseCleaner.clean } + +Spinach.hooks.before_run do + RSpec::Mocks::setup self + + stub_gitolite! +end From 698500dd786cc931cabeb0f44087c0cd11bd0131 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Mon, 10 Sep 2012 05:34:01 -0700 Subject: [PATCH 07/11] add spinach steps for project issues and source features --- features/project/issues/issues.feature | 5 +- features/project/issues/labels.feature | 11 +- features/project/issues/milestones.feature | 6 +- features/project/source/browse_files.feature | 14 +- features/project/source/git_blame.feature | 10 +- features/steps/project_browse_files.rb | 51 ++++++ features/steps/project_browse_git_repo.rb | 28 ++++ features/steps/project_issues.rb | 160 +++++++++++++++++++ features/steps/project_labels.rb | 33 ++++ features/steps/project_milestones.rb | 51 ++++++ features/support/env.rb | 2 + 11 files changed, 345 insertions(+), 26 deletions(-) create mode 100644 features/steps/project_browse_files.rb create mode 100644 features/steps/project_browse_git_repo.rb create mode 100644 features/steps/project_issues.rb create mode 100644 features/steps/project_labels.rb create mode 100644 features/steps/project_milestones.rb diff --git a/features/project/issues/issues.feature b/features/project/issues/issues.feature index b2301b3f..596e8bd7 100644 --- a/features/project/issues/issues.feature +++ b/features/project/issues/issues.feature @@ -1,6 +1,6 @@ -Feature: Issues +Feature: Project Issues Background: - Given I signin as a user + Given I sign in as a user And I own project "Shop" And project "Shop" have "Release 0.4" open issue And project "Shop" have "Release 0.3" closed issue @@ -79,4 +79,3 @@ Feature: Issues When I select first assignee from "Shop" project And I click link "New Issue" Then I should see first assignee from "Shop" as selected assignee - diff --git a/features/project/issues/labels.feature b/features/project/issues/labels.feature index 5a20bfd6..e601a41b 100644 --- a/features/project/issues/labels.feature +++ b/features/project/issues/labels.feature @@ -1,12 +1,9 @@ -Feature: Labels +Feature: Project Labels Background: - Given I signin as a user + Given I sign in as a user And I own project "Shop" - And project "Shop" have issues tags: - | name | - | bug | - | feature | - Given I visit project "Shop" labels page + And project "Shop" have issues tags: "bug", "feature" + Given I visit project "Shop" labels page Scenario: I should see active milestones Then I should see label "bug" diff --git a/features/project/issues/milestones.feature b/features/project/issues/milestones.feature index d78096a4..a57f67d6 100644 --- a/features/project/issues/milestones.feature +++ b/features/project/issues/milestones.feature @@ -1,9 +1,9 @@ -Feature: Milestones +Feature: Project Milestones Background: - Given I signin as a user + Given I sign in as a user And I own project "Shop" And project "Shop" has milestone "v2.2" - Given I visit project "Shop" milestones page + Given I visit project "Shop" milestones page Scenario: I should see active milestones Then I should see milestone "v2.2" diff --git a/features/project/source/browse_files.feature b/features/project/source/browse_files.feature index 04aebc19..b12b0ee3 100644 --- a/features/project/source/browse_files.feature +++ b/features/project/source/browse_files.feature @@ -1,6 +1,6 @@ -Feature: Browse git repo - Background: - Given I signin as a user +Feature: Project Browse files + Background: + Given I sign in as a user And I own project "Shop" Given I visit project source page @@ -12,12 +12,10 @@ Feature: Browse git repo Then I should see files from repository for "8470d70" Scenario: I browse file content - Given I click on file from repo + Given I click on "Gemfile" file in repo Then I should see it content Scenario: I browse raw file - Given I visit blob file from repo - And I click on raw button + Given I visit blob file from repo + And I click link "raw" Then I should see raw file content - - diff --git a/features/project/source/git_blame.feature b/features/project/source/git_blame.feature index 6aa6be47..93ed20a8 100644 --- a/features/project/source/git_blame.feature +++ b/features/project/source/git_blame.feature @@ -1,10 +1,10 @@ -Feature: Browse git repo - Background: - Given I signin as a user +Feature: Project Browse git repo + Background: + Given I sign in as a user And I own project "Shop" Given I visit project source page Scenario: I blame file - Given I click on file from repo + Given I click on "Gemfile" file in repo And I click blame button - Then I should see git file blame + Then I should see git file blame diff --git a/features/steps/project_browse_files.rb b/features/steps/project_browse_files.rb new file mode 100644 index 00000000..ad320584 --- /dev/null +++ b/features/steps/project_browse_files.rb @@ -0,0 +1,51 @@ +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 new file mode 100644 index 00000000..56b33a90 --- /dev/null +++ b/features/steps/project_browse_git_repo.rb @@ -0,0 +1,28 @@ +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_issues.rb b/features/steps/project_issues.rb new file mode 100644 index 00000000..c3fca0c6 --- /dev/null +++ b/features/steps/project_issues.rb @@ -0,0 +1,160 @@ +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 new file mode 100644 index 00000000..2e83824f --- /dev/null +++ b/features/steps/project_labels.rb @@ -0,0 +1,33 @@ +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_milestones.rb b/features/steps/project_milestones.rb new file mode 100644 index 00000000..97574d1c --- /dev/null +++ b/features/steps/project_milestones.rb @@ -0,0 +1,51 @@ +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/support/env.rb b/features/support/env.rb index 38d828a2..7bd89801 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -3,6 +3,7 @@ require './config/environment' require 'rspec' require 'database_cleaner' +require 'spinach/capybara' %w(gitolite_stub login_helpers stubbed_repository valid_commit).each do |f| require Rails.root.join('spec', 'support', f) @@ -12,6 +13,7 @@ include LoginHelpers include GitoliteStub WebMock.allow_net_connect! +Capybara.javascript_driver = :webkit DatabaseCleaner.strategy = :truncation Spinach.hooks.before_scenario { DatabaseCleaner.start } From b58155113b46690d9390597f9f1feccf44b00989 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Mon, 10 Sep 2012 06:35:23 -0700 Subject: [PATCH 08/11] 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 e69de29b..00000000 diff --git a/features/project/merge_requests.feature b/features/project/merge_requests.feature index 54b6ccde..80f00986 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 61c05eb3..31ce5ad3 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 895a928f..1c9f201d 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 e69de29b..00000000 diff --git a/features/project/team_management.feature b/features/project/team_management.feature index b5b485e2..ae0c459f 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 ed675e2c..c92dbf82 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 e69de29b..00000000 diff --git a/features/project/wiki.feature b/features/project/wiki.feature index 4441ada2..51370565 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 00000000..80f6f708 --- /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 00000000..666a65fa --- /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 00000000..8515e7e8 --- /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 00000000..d87f3d82 --- /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 00000000..9cee75bd --- /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 00000000..b94bd0bb --- /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 00000000..8c8c7c8d --- /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 From ae9689f8ffdf8a69bd803021d1f57a37aba06e0d Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Mon, 10 Sep 2012 06:40:57 -0700 Subject: [PATCH 09/11] remove cucumber completely --- Gemfile | 2 -- Gemfile.lock | 16 ---------- config/cucumber.yml | 8 ----- lib/tasks/cucumber.rake | 65 -------------------------------------- lib/tasks/gitlab/test.rake | 5 ++- lib/tasks/travis.rake | 2 +- script/cucumber | 10 ------ 7 files changed, 3 insertions(+), 105 deletions(-) delete mode 100644 config/cucumber.yml delete mode 100644 lib/tasks/cucumber.rake delete mode 100755 script/cucumber diff --git a/Gemfile b/Gemfile index 4e957e92..0609f6fd 100644 --- a/Gemfile +++ b/Gemfile @@ -119,7 +119,6 @@ group :development, :test do # Guard gem 'guard-rspec' - gem 'guard-cucumber' # Notification gem 'rb-fsevent', :require => darwin_only('rb-fsevent') @@ -128,7 +127,6 @@ group :development, :test do end group :test do - gem 'cucumber-rails', :require => false gem "simplecov", :require => false gem "shoulda-matchers" gem 'email_spec' diff --git a/Gemfile.lock b/Gemfile.lock index 317ff694..38094518 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -134,15 +134,6 @@ GEM colored (1.2) colorize (0.5.8) crack (0.3.1) - cucumber (1.2.1) - builder (>= 2.1.2) - diff-lcs (>= 1.1.3) - gherkin (~> 2.11.0) - json (>= 1.4.6) - cucumber-rails (1.3.0) - capybara (>= 1.1.2) - cucumber (>= 1.1.8) - nokogiri (>= 1.5.0) daemons (1.1.8) database_cleaner (0.8.0) devise (2.1.2) @@ -171,8 +162,6 @@ GEM ffi (1.0.11) foreman (0.47.0) thor (>= 0.13.6) - gherkin (2.11.0) - json (>= 1.4.6) gherkin-ruby (0.2.1) git (1.2.5) github-markup (0.7.4) @@ -187,9 +176,6 @@ GEM guard (1.3.2) listen (>= 0.4.2) thor (>= 0.14.6) - guard-cucumber (1.2.0) - cucumber (>= 1.2.0) - guard (>= 1.1.0) guard-rspec (1.2.1) guard (>= 1.1) haml (3.1.6) @@ -403,7 +389,6 @@ DEPENDENCIES chosen-rails coffee-rails (= 3.2.2) colored - cucumber-rails database_cleaner devise (~> 2.1.0) draper @@ -419,7 +404,6 @@ DEPENDENCIES grape (~> 0.2.1) grit! growl - guard-cucumber guard-rspec haml-rails headless diff --git a/config/cucumber.yml b/config/cucumber.yml deleted file mode 100644 index 19b288df..00000000 --- a/config/cucumber.yml +++ /dev/null @@ -1,8 +0,0 @@ -<% -rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : "" -rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}" -std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip" -%> -default: <%= std_opts %> features -wip: --tags @wip:3 --wip features -rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip diff --git a/lib/tasks/cucumber.rake b/lib/tasks/cucumber.rake deleted file mode 100644 index 83f79471..00000000 --- a/lib/tasks/cucumber.rake +++ /dev/null @@ -1,65 +0,0 @@ -# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril. -# It is recommended to regenerate this file in the future when you upgrade to a -# newer version of cucumber-rails. Consider adding your own code to a new file -# instead of editing this one. Cucumber will automatically load all features/**/*.rb -# files. - - -unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks - -vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first -$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil? - -begin - require 'cucumber/rake/task' - - namespace :cucumber do - Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t| - t.binary = vendored_cucumber_bin # If nil, the gem's binary is used. - t.fork = true # You may get faster startup if you set this to false - t.profile = 'default' - end - - Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t| - t.binary = vendored_cucumber_bin - t.fork = true # You may get faster startup if you set this to false - t.profile = 'wip' - end - - Cucumber::Rake::Task.new({:rerun => 'db:test:prepare'}, 'Record failing features and run only them if any exist') do |t| - t.binary = vendored_cucumber_bin - t.fork = true # You may get faster startup if you set this to false - t.profile = 'rerun' - end - - desc 'Run all features' - task :all => [:ok, :wip] - - task :statsetup do - require 'rails/code_statistics' - ::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?('features') - ::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?('features') - end - end - desc 'Alias for cucumber:ok' - task :cucumber => 'cucumber:ok' - - task :default => :cucumber - - task :features => :cucumber do - STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***" - end - - # In case we don't have ActiveRecord, append a no-op task that we can depend upon. - task 'db:test:prepare' do - end - - task :stats => 'cucumber:statsetup' -rescue LoadError - desc 'cucumber rake task not available (cucumber not installed)' - task :cucumber do - abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin' - end -end - -end diff --git a/lib/tasks/gitlab/test.rake b/lib/tasks/gitlab/test.rake index 77e148cf..ad1bfb2e 100644 --- a/lib/tasks/gitlab/test.rake +++ b/lib/tasks/gitlab/test.rake @@ -1,5 +1,4 @@ namespace :gitlab do - desc "GITLAB | Run both cucumber & rspec" - task :test => ['cucumber', 'spec'] + desc "GITLAB | Run both spinach and rspec" + task :test => ['spinach', 'spec'] end - diff --git a/lib/tasks/travis.rake b/lib/tasks/travis.rake index 58767e10..13e32135 100644 --- a/lib/tasks/travis.rake +++ b/lib/tasks/travis.rake @@ -1,5 +1,5 @@ task :travis do - ["cucumber", "rspec spec"].each do |cmd| + ["spinach", "rspec spec"].each do |cmd| puts "Starting to run #{cmd}..." system("export DISPLAY=:99.0 && bundle exec #{cmd}") raise "#{cmd} failed!" unless $?.exitstatus == 0 diff --git a/script/cucumber b/script/cucumber deleted file mode 100755 index 7fa5c920..00000000 --- a/script/cucumber +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env ruby - -vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first -if vendored_cucumber_bin - load File.expand_path(vendored_cucumber_bin) -else - require 'rubygems' unless ENV['NO_RUBYGEMS'] - require 'cucumber' - load Cucumber::BINARY -end From ef4e9c24d3dc870eb194591522dda6ec8dde7192 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Mon, 10 Sep 2012 06:43:49 -0700 Subject: [PATCH 10/11] install guard-spinach --- Gemfile | 1 + Gemfile.lock | 4 ++++ Guardfile | 16 ++++++---------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Gemfile b/Gemfile index 0609f6fd..0a5f730d 100644 --- a/Gemfile +++ b/Gemfile @@ -119,6 +119,7 @@ group :development, :test do # Guard gem 'guard-rspec' + gem 'guard-spinach' # Notification gem 'rb-fsevent', :require => darwin_only('rb-fsevent') diff --git a/Gemfile.lock b/Gemfile.lock index 38094518..8046b92b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -178,6 +178,9 @@ GEM thor (>= 0.14.6) guard-rspec (1.2.1) guard (>= 1.1) + guard-spinach (0.0.2) + guard (>= 1.1) + spinach haml (3.1.6) haml-rails (0.3.4) actionpack (~> 3.0) @@ -405,6 +408,7 @@ DEPENDENCIES grit! growl guard-rspec + guard-spinach haml-rails headless httparty diff --git a/Guardfile b/Guardfile index ed38f548..6ed414bc 100644 --- a/Guardfile +++ b/Guardfile @@ -13,18 +13,14 @@ guard 'rspec', :version => 2 do watch(%r{^spec/support/(.+)\.rb$}) { "spec" } watch('config/routes.rb') { "spec/routing" } watch('app/controllers/application_controller.rb') { "spec/controllers" } - + # Capybara request specs watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" } - - # Turnip features and steps - watch(%r{^spec/acceptance/(.+)\.feature$}) - watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' } end - -guard 'cucumber' do - watch(%r{^features/.+\.feature$}) - watch(%r{^features/support/.+$}) { 'features' } - watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' } +guard 'spinach' do + watch(%r|^features/(.*)\.feature|) + watch(%r|^features/steps/(.*)([^/]+)\.rb|) do |m| + "features/#{m[1]}#{m[2]}.feature" + end end From 79eb5ab396690c613ea6e13c3c941ba1fa80f217 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Mon, 10 Sep 2012 08:35:03 -0700 Subject: [PATCH 11/11] refactor feature steps --- features/project/create_project.feature | 2 +- features/project/wall.feature | 6 +- features/steps/{ => dashboard}/dashboard.rb | 11 +- .../steps/{ => dashboard}/dashboard_issues.rb | 21 +--- .../dashboard_merge_requests.rb | 20 +--- .../steps/{ => dashboard}/dashboard_search.rb | 11 +- features/steps/{ => profile}/profile.rb | 17 +-- .../steps/{ => profile}/profile_ssh_keys.rb | 6 +- features/steps/project.rb | 15 --- .../steps/{ => project}/create_project.rb | 11 +- features/steps/project/project.rb | 5 + .../{ => project}/project_browse_branches.rb | 17 +-- .../{ => project}/project_browse_commits.rb | 21 +--- .../{ => project}/project_browse_files.rb | 25 +--- .../{ => project}/project_browse_git_repo.rb | 17 +-- features/steps/project/project_browse_tags.rb | 10 ++ .../steps/project/project_comment_commit.rb | 6 + .../steps/{ => project}/project_issues.rb | 40 ++----- .../steps/{ => project}/project_labels.rb | 17 +-- .../{ => project}/project_merge_requests.rb | 32 +---- .../steps/{ => project}/project_milestones.rb | 22 +--- .../{ => project}/project_network_graph.rb | 12 +- .../{ => project}/project_team_management.rb | 17 +-- features/steps/project/project_wall.rb | 6 + features/steps/project/project_wiki.rb | 20 ++++ features/steps/project_browse_tags.rb | 19 --- features/steps/project_comment_commit.rb | 23 ---- 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 +- 34 files changed, 270 insertions(+), 376 deletions(-) rename features/steps/{ => dashboard}/dashboard.rb (95%) rename features/steps/{ => dashboard}/dashboard_issues.rb (52%) rename features/steps/{ => dashboard}/dashboard_merge_requests.rb (58%) rename features/steps/{ => dashboard}/dashboard_search.rb (74%) rename features/steps/{ => profile}/profile.rb (80%) rename features/steps/{ => profile}/profile_ssh_keys.rb (94%) delete mode 100644 features/steps/project.rb rename features/steps/{ => project}/create_project.rb (76%) create mode 100644 features/steps/project/project.rb rename features/steps/{ => project}/project_browse_branches.rb (73%) rename features/steps/{ => project}/project_browse_commits.rb (79%) rename features/steps/{ => project}/project_browse_files.rb (58%) rename features/steps/{ => project}/project_browse_git_repo.rb (57%) create mode 100644 features/steps/project/project_browse_tags.rb create mode 100644 features/steps/project/project_comment_commit.rb rename features/steps/{ => project}/project_issues.rb (80%) rename features/steps/{ => project}/project_labels.rb (62%) rename features/steps/{ => project}/project_merge_requests.rb (73%) rename features/steps/{ => project}/project_milestones.rb (70%) rename features/steps/{ => project}/project_network_graph.rb (76%) rename features/steps/{ => project}/project_team_management.rb (89%) 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_tags.rb delete mode 100644 features/steps/project_comment_commit.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 42d25b3f..b7cdfdb8 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 c92dbf82..c38d046a 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/dashboard.rb b/features/steps/dashboard/dashboard.rb similarity index 95% rename from features/steps/dashboard.rb rename to features/steps/dashboard/dashboard.rb index e69686b3..6c603bbe 100644 --- a/features/steps/dashboard.rb +++ b/features/steps/dashboard/dashboard.rb @@ -1,4 +1,7 @@ class Dashboard < Spinach::FeatureSteps + include SharedAuthentication + include SharedPaths + Then 'I should see "New Project" link' do page.should have_link "New Project" end @@ -38,10 +41,6 @@ class Dashboard < Spinach::FeatureSteps ) 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 @@ -60,10 +59,6 @@ class Dashboard < Spinach::FeatureSteps 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) diff --git a/features/steps/dashboard_issues.rb b/features/steps/dashboard/dashboard_issues.rb similarity index 52% rename from features/steps/dashboard_issues.rb rename to features/steps/dashboard/dashboard_issues.rb index 8704d2ef..9368782b 100644 --- a/features/steps/dashboard_issues.rb +++ b/features/steps/dashboard/dashboard_issues.rb @@ -1,4 +1,7 @@ class DashboardIssues < Spinach::FeatureSteps + include SharedAuthentication + include SharedPaths + Then 'I should see issues assigned to me' do issues = @user.issues issues.each do |issue| @@ -7,26 +10,10 @@ class DashboardIssues < Spinach::FeatureSteps 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 + 2.times { Factory :issue, :author => @user, :assignee => @user, :project => project } end end diff --git a/features/steps/dashboard_merge_requests.rb b/features/steps/dashboard/dashboard_merge_requests.rb similarity index 58% rename from features/steps/dashboard_merge_requests.rb rename to features/steps/dashboard/dashboard_merge_requests.rb index 3e057ef9..fc339e75 100644 --- a/features/steps/dashboard_merge_requests.rb +++ b/features/steps/dashboard/dashboard_merge_requests.rb @@ -1,4 +1,7 @@ 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| @@ -7,10 +10,6 @@ class DashboardMergeRequests < Spinach::FeatureSteps 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 @@ -18,16 +17,7 @@ class DashboardMergeRequests < Spinach::FeatureSteps 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 + 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_search.rb b/features/steps/dashboard/dashboard_search.rb similarity index 74% rename from features/steps/dashboard_search.rb rename to features/steps/dashboard/dashboard_search.rb index 122774fc..e3585898 100644 --- a/features/steps/dashboard_search.rb +++ b/features/steps/dashboard/dashboard_search.rb @@ -1,4 +1,7 @@ class DashboardSearch < Spinach::FeatureSteps + include SharedAuthentication + include SharedPaths + Given 'I search for "Sho"' do fill_in "dashboard_search", :with => "Sho" click_button "Search" @@ -8,16 +11,8 @@ class DashboardSearch < Spinach::FeatureSteps 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/profile.rb similarity index 80% rename from features/steps/profile.rb rename to features/steps/profile/profile.rb index c7e6be3f..d3261a16 100644 --- a/features/steps/profile.rb +++ b/features/steps/profile/profile.rb @@ -1,7 +1,6 @@ class Profile < Spinach::FeatureSteps - Given 'I visit profile page' do - visit profile_path - end + include SharedAuthentication + include SharedPaths Then 'I should see my profile info' do page.should have_content "Profile" @@ -23,10 +22,6 @@ class Profile < Spinach::FeatureSteps @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" @@ -37,10 +32,6 @@ class Profile < Spinach::FeatureSteps 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" @@ -50,8 +41,4 @@ class Profile < Spinach::FeatureSteps 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_ssh_keys.rb b/features/steps/profile/profile_ssh_keys.rb similarity index 94% rename from features/steps/profile_ssh_keys.rb rename to features/steps/profile/profile_ssh_keys.rb index 9360f66f..96df2d73 100644 --- a/features/steps/profile_ssh_keys.rb +++ b/features/steps/profile/profile_ssh_keys.rb @@ -1,4 +1,6 @@ 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) @@ -40,10 +42,6 @@ class ProfileSshKeys < Spinach::FeatureSteps 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 diff --git a/features/steps/project.rb b/features/steps/project.rb deleted file mode 100644 index 666a65fa..00000000 --- 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/create_project.rb b/features/steps/project/create_project.rb similarity index 76% rename from features/steps/create_project.rb rename to features/steps/project/create_project.rb index 80f6f708..6d2ca3f9 100644 --- a/features/steps/create_project.rb +++ b/features/steps/project/create_project.rb @@ -1,11 +1,6 @@ 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 + include SharedAuthentication + include SharedPaths And 'fill project form with valid data' do fill_in 'project_name', :with => 'NewProject' @@ -16,7 +11,7 @@ class CreateProject < Spinach::FeatureSteps Then 'I should see project page' do current_path.should == project_path(Project.last) - page.should have_content('NewProject') + page.should have_content "NewProject" end And 'I should see empty project instuctions' do diff --git a/features/steps/project/project.rb b/features/steps/project/project.rb new file mode 100644 index 00000000..f33f12eb --- /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_browse_branches.rb b/features/steps/project/project_browse_branches.rb similarity index 73% rename from features/steps/project_browse_branches.rb rename to features/steps/project/project_browse_branches.rb index 9fb2e59d..2f6e185d 100644 --- a/features/steps/project_browse_branches.rb +++ b/features/steps/project/project_browse_branches.rb @@ -1,4 +1,8 @@ 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" @@ -24,21 +28,8 @@ class ProjectBrowseBranches < Spinach::FeatureSteps 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/project_browse_commits.rb similarity index 79% rename from features/steps/project_browse_commits.rb rename to features/steps/project/project_browse_commits.rb index 71c592a7..01479987 100644 --- a/features/steps/project_browse_commits.rb +++ b/features/steps/project/project_browse_commits.rb @@ -1,4 +1,8 @@ class ProjectBrowseCommits < Spinach::FeatureSteps + include SharedAuthentication + include SharedProject + include SharedPaths + Then 'I see project commits' do current_path.should == project_commits_path(@project) @@ -29,10 +33,6 @@ class ProjectBrowseCommits < Spinach::FeatureSteps 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" @@ -44,17 +44,4 @@ class ProjectBrowseCommits < Spinach::FeatureSteps 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/project_browse_files.rb similarity index 58% rename from features/steps/project_browse_files.rb rename to features/steps/project/project_browse_files.rb index ad320584..67c553ce 100644 --- a/features/steps/project_browse_files.rb +++ b/features/steps/project/project_browse_files.rb @@ -1,14 +1,14 @@ 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 - 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" @@ -24,10 +24,6 @@ class ProjectBrowseFiles < Spinach::FeatureSteps 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 @@ -35,17 +31,4 @@ class ProjectBrowseFiles < Spinach::FeatureSteps 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/project_browse_git_repo.rb similarity index 57% rename from features/steps/project_browse_git_repo.rb rename to features/steps/project/project_browse_git_repo.rb index 56b33a90..e966f407 100644 --- a/features/steps/project_browse_git_repo.rb +++ b/features/steps/project/project_browse_git_repo.rb @@ -1,4 +1,8 @@ class ProjectBrowseGitRepo < Spinach::FeatureSteps + include SharedAuthentication + include SharedProject + include SharedPaths + Given 'I click on "Gemfile" file in repo' do click_link "Gemfile" end @@ -12,17 +16,4 @@ class ProjectBrowseGitRepo < Spinach::FeatureSteps 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/project_browse_tags.rb b/features/steps/project/project_browse_tags.rb new file mode 100644 index 00000000..0cbfa0d8 --- /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 00000000..cb8385e1 --- /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_issues.rb b/features/steps/project/project_issues.rb similarity index 80% rename from features/steps/project_issues.rb rename to features/steps/project/project_issues.rb index c3fca0c6..64af2449 100644 --- a/features/steps/project_issues.rb +++ b/features/steps/project/project_issues.rb @@ -1,4 +1,9 @@ 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 @@ -51,20 +56,6 @@ class ProjectIssues < Spinach::FeatureSteps 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 @@ -90,22 +81,14 @@ class ProjectIssues < Spinach::FeatureSteps 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 + 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 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")) + 3.times { Factory :issue, :project => project, :milestone => milestone } end When 'I select milestone "v3.0"' do @@ -132,15 +115,6 @@ class ProjectIssues < Spinach::FeatureSteps 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, diff --git a/features/steps/project_labels.rb b/features/steps/project/project_labels.rb similarity index 62% rename from features/steps/project_labels.rb rename to features/steps/project/project_labels.rb index 2e83824f..1a347bf3 100644 --- a/features/steps/project_labels.rb +++ b/features/steps/project/project_labels.rb @@ -1,4 +1,8 @@ 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" @@ -11,23 +15,10 @@ class ProjectLabels < Spinach::FeatureSteps 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/project_merge_requests.rb similarity index 73% rename from features/steps/project_merge_requests.rb rename to features/steps/project/project_merge_requests.rb index 8515e7e8..80e83906 100644 --- a/features/steps/project_merge_requests.rb +++ b/features/steps/project/project_merge_requests.rb @@ -1,4 +1,9 @@ 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 @@ -56,29 +61,6 @@ class ProjectMergeRequests < Spinach::FeatureSteps 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, @@ -95,8 +77,4 @@ class ProjectMergeRequests < Spinach::FeatureSteps :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/project_milestones.rb similarity index 70% rename from features/steps/project_milestones.rb rename to features/steps/project/project_milestones.rb index 97574d1c..83ed6859 100644 --- a/features/steps/project_milestones.rb +++ b/features/steps/project/project_milestones.rb @@ -1,4 +1,8 @@ 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]) @@ -26,26 +30,10 @@ class ProjectMilestones < Spinach::FeatureSteps 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) + 3.times { Factory :issue, :project => project, :milestone => milestone } end end diff --git a/features/steps/project_network_graph.rb b/features/steps/project/project_network_graph.rb similarity index 76% rename from features/steps/project_network_graph.rb rename to features/steps/project/project_network_graph.rb index d87f3d82..f34a81a4 100644 --- a/features/steps/project_network_graph.rb +++ b/features/steps/project/project_network_graph.rb @@ -1,4 +1,7 @@ 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 @@ -7,15 +10,6 @@ class ProjectNetworkGraph < Spinach::FeatureSteps 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") diff --git a/features/steps/project_team_management.rb b/features/steps/project/project_team_management.rb similarity index 89% rename from features/steps/project_team_management.rb rename to features/steps/project/project_team_management.rb index 9cee75bd..7beca257 100644 --- a/features/steps/project_team_management.rb +++ b/features/steps/project/project_team_management.rb @@ -1,4 +1,8 @@ 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) @@ -42,10 +46,6 @@ class ProjectTeamManagement < Spinach::FeatureSteps 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 @@ -73,15 +73,6 @@ class ProjectTeamManagement < Spinach::FeatureSteps 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 diff --git a/features/steps/project/project_wall.rb b/features/steps/project/project_wall.rb new file mode 100644 index 00000000..ba9d3533 --- /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 00000000..902e9ce1 --- /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_tags.rb b/features/steps/project_browse_tags.rb deleted file mode 100644 index c6bea691..00000000 --- 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 04e94c7d..00000000 --- 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_wall.rb b/features/steps/project_wall.rb deleted file mode 100644 index b94bd0bb..00000000 --- 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 8c8c7c8d..00000000 --- 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 00000000..77d9839f --- /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 00000000..923e69b6 --- /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 00000000..05ae88e6 --- /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 00000000..9b64ca59 --- /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 7bd89801..9c6cef07 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!