Commit d74f54736b8aabb3885648c44d7e253209b8e9e1
1 parent
bb75052a
Exists in
master
and in
4 other branches
rewrite dashboard feature steps using spinach
Showing
9 changed files
with
205 additions
and
17 deletions
Show diff stats
features/dashboard/dashboard.feature
| 1 | Feature: Dashboard | 1 | Feature: Dashboard |
| 2 | - Background: | ||
| 3 | - Given I signin as a user | 2 | + Background: |
| 3 | + Given I sign in as a user | ||
| 4 | And I own project "Shop" | 4 | And I own project "Shop" |
| 5 | And project "Shop" has push event | 5 | And project "Shop" has push event |
| 6 | - And I visit dashboard page | 6 | + And I visit dashboard page |
| 7 | 7 | ||
| 8 | Scenario: I should see projects list | 8 | Scenario: I should see projects list |
| 9 | Then I should see "New Project" link | 9 | Then I should see "New Project" link |
| @@ -25,4 +25,3 @@ Feature: Dashboard | @@ -25,4 +25,3 @@ Feature: Dashboard | ||
| 25 | And user with name "John Doe" left project "Shop" | 25 | And user with name "John Doe" left project "Shop" |
| 26 | When I visit dashboard page | 26 | When I visit dashboard page |
| 27 | Then I should see "John Doe left project Shop" event | 27 | Then I should see "John Doe left project Shop" event |
| 28 | - |
features/dashboard/issues.feature
| 1 | Feature: Dashboard Issues | 1 | Feature: Dashboard Issues |
| 2 | - Background: | ||
| 3 | - Given I signin as a user | 2 | + Background: |
| 3 | + Given I sign in as a user | ||
| 4 | And I have assigned issues | 4 | And I have assigned issues |
| 5 | - And I visit dashboard issues page | 5 | + And I visit dashboard issues page |
| 6 | 6 | ||
| 7 | Scenario: I should see issues list | 7 | Scenario: I should see issues list |
| 8 | Then I should see issues assigned to me | 8 | Then I should see issues assigned to me |
features/dashboard/merge_requests.feature
| 1 | -Feature: Dashboard MR | ||
| 2 | - Background: | ||
| 3 | - Given I signin as a user | 1 | +Feature: Dashboard Merge Requests |
| 2 | + Background: | ||
| 3 | + Given I sign in as a user | ||
| 4 | And I have authored merge requests | 4 | And I have authored merge requests |
| 5 | - And I visit dashboard merge requests page | 5 | + And I visit dashboard merge requests page |
| 6 | 6 | ||
| 7 | Scenario: I should see projects list | 7 | Scenario: I should see projects list |
| 8 | Then I should see my merge requests | 8 | Then I should see my merge requests |
features/dashboard/search.feature
| 1 | Feature: Dashboard Search | 1 | Feature: Dashboard Search |
| 2 | - Background: | ||
| 3 | - Given I signin as a user | 2 | + Background: |
| 3 | + Given I sign in as a user | ||
| 4 | And I own project "Shop" | 4 | And I own project "Shop" |
| 5 | - And I visit dashboard search page | 5 | + And I visit dashboard search page |
| 6 | 6 | ||
| 7 | - Scenario: I should see project i'm looking for | 7 | + Scenario: I should see project I am looking for |
| 8 | Given I search for "Sho" | 8 | Given I search for "Sho" |
| 9 | Then I should see "Shop" project link | 9 | Then I should see "Shop" project link |
| 10 | - | ||
| 11 | - |
| @@ -0,0 +1,97 @@ | @@ -0,0 +1,97 @@ | ||
| 1 | +class Dashboard < Spinach::FeatureSteps | ||
| 2 | + Then 'I should see "New Project" link' do | ||
| 3 | + page.should have_link "New Project" | ||
| 4 | + end | ||
| 5 | + | ||
| 6 | + Then 'I should see "Shop" project link' do | ||
| 7 | + page.should have_link "Shop" | ||
| 8 | + end | ||
| 9 | + | ||
| 10 | + Then 'I should see project "Shop" activity feed' do | ||
| 11 | + project = Project.find_by_name("Shop") | ||
| 12 | + page.should have_content "#{@user.name} pushed new branch new_design at #{project.name}" | ||
| 13 | + end | ||
| 14 | + | ||
| 15 | + Then 'I should see last push widget' do | ||
| 16 | + page.should have_content "Your pushed to branch new_design" | ||
| 17 | + page.should have_link "Create Merge Request" | ||
| 18 | + end | ||
| 19 | + | ||
| 20 | + And 'I click "Create Merge Request" link' do | ||
| 21 | + click_link "Create Merge Request" | ||
| 22 | + end | ||
| 23 | + | ||
| 24 | + Then 'I see prefilled new Merge Request page' do | ||
| 25 | + current_path.should == new_project_merge_request_path(@project) | ||
| 26 | + find("#merge_request_source_branch").value.should == "new_design" | ||
| 27 | + find("#merge_request_target_branch").value.should == "master" | ||
| 28 | + find("#merge_request_title").value.should == "New Design" | ||
| 29 | + end | ||
| 30 | + | ||
| 31 | + Given 'user with name "John Doe" joined project "Shop"' do | ||
| 32 | + user = Factory.create(:user, {name: "John Doe"}) | ||
| 33 | + project = Project.find_by_name "Shop" | ||
| 34 | + Event.create( | ||
| 35 | + project: project, | ||
| 36 | + author_id: user.id, | ||
| 37 | + action: Event::Joined | ||
| 38 | + ) | ||
| 39 | + end | ||
| 40 | + | ||
| 41 | + When 'I visit dashboard page' do | ||
| 42 | + visit dashboard_path | ||
| 43 | + end | ||
| 44 | + | ||
| 45 | + Then 'I should see "John Doe joined project Shop" event' do | ||
| 46 | + page.should have_content "John Doe joined project Shop" | ||
| 47 | + end | ||
| 48 | + | ||
| 49 | + And 'user with name "John Doe" left project "Shop"' do | ||
| 50 | + user = User.find_by_name "John Doe" | ||
| 51 | + project = Project.find_by_name "Shop" | ||
| 52 | + Event.create( | ||
| 53 | + project: project, | ||
| 54 | + author_id: user.id, | ||
| 55 | + action: Event::Left | ||
| 56 | + ) | ||
| 57 | + end | ||
| 58 | + | ||
| 59 | + Then 'I should see "John Doe left project Shop" event' do | ||
| 60 | + page.should have_content "John Doe left project Shop" | ||
| 61 | + end | ||
| 62 | + | ||
| 63 | + Given 'I sign in as a user' do | ||
| 64 | + login_as :user | ||
| 65 | + end | ||
| 66 | + | ||
| 67 | + And 'I own project "Shop"' do | ||
| 68 | + @project = Factory :project, :name => 'Shop' | ||
| 69 | + @project.add_access(@user, :admin) | ||
| 70 | + end | ||
| 71 | + | ||
| 72 | + And 'project "Shop" has push event' do | ||
| 73 | + @project = Project.find_by_name("Shop") | ||
| 74 | + | ||
| 75 | + data = { | ||
| 76 | + :before => "0000000000000000000000000000000000000000", | ||
| 77 | + :after => "0220c11b9a3e6c69dc8fd35321254ca9a7b98f7e", | ||
| 78 | + :ref => "refs/heads/new_design", | ||
| 79 | + :user_id => @user.id, | ||
| 80 | + :user_name => @user.name, | ||
| 81 | + :repository => { | ||
| 82 | + :name => @project.name, | ||
| 83 | + :url => "localhost/rubinius", | ||
| 84 | + :description => "", | ||
| 85 | + :homepage => "localhost/rubinius", | ||
| 86 | + :private => true | ||
| 87 | + } | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + @event = Event.create( | ||
| 91 | + :project => @project, | ||
| 92 | + :action => Event::Pushed, | ||
| 93 | + :data => data, | ||
| 94 | + :author_id => @user.id | ||
| 95 | + ) | ||
| 96 | + end | ||
| 97 | +end |
| @@ -0,0 +1,32 @@ | @@ -0,0 +1,32 @@ | ||
| 1 | +class DashboardIssues < Spinach::FeatureSteps | ||
| 2 | + Then 'I should see issues assigned to me' do | ||
| 3 | + issues = @user.issues | ||
| 4 | + issues.each do |issue| | ||
| 5 | + page.should have_content(issue.title[0..10]) | ||
| 6 | + page.should have_content(issue.project.name) | ||
| 7 | + end | ||
| 8 | + end | ||
| 9 | + | ||
| 10 | + Given 'I sign in as a user' do | ||
| 11 | + login_as :user | ||
| 12 | + end | ||
| 13 | + | ||
| 14 | + And 'I have assigned issues' do | ||
| 15 | + project = Factory :project | ||
| 16 | + project.add_access(@user, :read, :write) | ||
| 17 | + | ||
| 18 | + issue1 = Factory :issue, | ||
| 19 | + :author => @user, | ||
| 20 | + :assignee => @user, | ||
| 21 | + :project => project | ||
| 22 | + | ||
| 23 | + issue2 = Factory :issue, | ||
| 24 | + :author => @user, | ||
| 25 | + :assignee => @user, | ||
| 26 | + :project => project | ||
| 27 | + end | ||
| 28 | + | ||
| 29 | + And 'I visit dashboard issues page' do | ||
| 30 | + visit dashboard_issues_path | ||
| 31 | + end | ||
| 32 | +end |
| @@ -0,0 +1,33 @@ | @@ -0,0 +1,33 @@ | ||
| 1 | +class DashboardMergeRequests < Spinach::FeatureSteps | ||
| 2 | + Then 'I should see my merge requests' do | ||
| 3 | + merge_requests = @user.merge_requests | ||
| 4 | + merge_requests.each do |mr| | ||
| 5 | + page.should have_content(mr.title[0..10]) | ||
| 6 | + page.should have_content(mr.project.name) | ||
| 7 | + end | ||
| 8 | + end | ||
| 9 | + | ||
| 10 | + Given 'I sign in as a user' do | ||
| 11 | + login_as :user | ||
| 12 | + end | ||
| 13 | + | ||
| 14 | + And 'I have authored merge requests' do | ||
| 15 | + project1 = Factory :project | ||
| 16 | + project2 = Factory :project | ||
| 17 | + | ||
| 18 | + project1.add_access(@user, :read, :write) | ||
| 19 | + project2.add_access(@user, :read, :write) | ||
| 20 | + | ||
| 21 | + merge_request1 = Factory :merge_request, | ||
| 22 | + :author => @user, | ||
| 23 | + :project => project1 | ||
| 24 | + | ||
| 25 | + merge_request2 = Factory :merge_request, | ||
| 26 | + :author => @user, | ||
| 27 | + :project => project2 | ||
| 28 | + end | ||
| 29 | + | ||
| 30 | + And 'I visit dashboard merge requests page' do | ||
| 31 | + visit dashboard_merge_requests_path | ||
| 32 | + end | ||
| 33 | +end |
| @@ -0,0 +1,23 @@ | @@ -0,0 +1,23 @@ | ||
| 1 | +class DashboardSearch < Spinach::FeatureSteps | ||
| 2 | + Given 'I search for "Sho"' do | ||
| 3 | + fill_in "dashboard_search", :with => "Sho" | ||
| 4 | + click_button "Search" | ||
| 5 | + end | ||
| 6 | + | ||
| 7 | + Then 'I should see "Shop" project link' do | ||
| 8 | + page.should have_link "Shop" | ||
| 9 | + end | ||
| 10 | + | ||
| 11 | + Given 'I sign in as a user' do | ||
| 12 | + login_as :user | ||
| 13 | + end | ||
| 14 | + | ||
| 15 | + And 'I own project "Shop"' do | ||
| 16 | + @project = Factory :project, :name => "Shop" | ||
| 17 | + @project.add_access(@user, :admin) | ||
| 18 | + end | ||
| 19 | + | ||
| 20 | + And 'I visit dashboard search page' do | ||
| 21 | + visit search_path | ||
| 22 | + end | ||
| 23 | +end |
features/support/env.rb
| @@ -4,6 +4,12 @@ require './config/environment' | @@ -4,6 +4,12 @@ require './config/environment' | ||
| 4 | require 'rspec' | 4 | require 'rspec' |
| 5 | require 'database_cleaner' | 5 | require 'database_cleaner' |
| 6 | 6 | ||
| 7 | +%w(login_helpers stubbed_repository).each do |f| | ||
| 8 | + require Rails.root.join('spec', 'support', f) | ||
| 9 | +end | ||
| 10 | + | ||
| 11 | +include LoginHelpers | ||
| 12 | + | ||
| 7 | DatabaseCleaner.strategy = :transaction | 13 | DatabaseCleaner.strategy = :transaction |
| 8 | Spinach.hooks.before_scenario { DatabaseCleaner.start } | 14 | Spinach.hooks.before_scenario { DatabaseCleaner.start } |
| 9 | Spinach.hooks.after_scenario { DatabaseCleaner.clean } | 15 | Spinach.hooks.after_scenario { DatabaseCleaner.clean } |