diff options
author | Ciro Santilli <ciro.santilli@gmail.com> | 2014-06-26 11:49:14 +0400 |
---|---|---|
committer | Ciro Santilli <ciro.santilli@gmail.com> | 2014-07-18 00:47:16 +0400 |
commit | 714f7201d3362793d11f33793e5ef6dc83bdd2f0 (patch) | |
tree | 54e6a4cc5ef89e132a123231b439b83de0e54d54 /features | |
parent | b634d2801e6abdd039447f53ec5d9cf709f66b06 (diff) |
Add project stars.
Diffstat (limited to 'features')
-rw-r--r-- | features/project/star.feature | 48 | ||||
-rw-r--r-- | features/steps/project/star.rb | 29 | ||||
-rw-r--r-- | features/steps/public/projects.rb | 24 | ||||
-rw-r--r-- | features/steps/shared/authentication.rb | 4 | ||||
-rw-r--r-- | features/steps/shared/paths.rb | 32 | ||||
-rw-r--r-- | features/steps/shared/project.rb | 8 | ||||
-rw-r--r-- | features/steps/shared/user.rb | 5 |
7 files changed, 122 insertions, 28 deletions
diff --git a/features/project/star.feature b/features/project/star.feature new file mode 100644 index 00000000000..e6cbc78125b --- /dev/null +++ b/features/project/star.feature @@ -0,0 +1,48 @@ +Feature: Project Star + Scenario: New projects have 0 stars + Given public project "Community" + When I visit project "Community" page + Then The project has 0 stars + + Scenario: Empty projects show star count + Given public empty project "Empty Public Project" + When I visit empty project page + Then The project has 0 stars + + Scenario: Signed off users can't star projects + Given public project "Community" + And I visit project "Community" page + When I click on the star toggle button + Then The project has 0 stars + + @javascript + Scenario: Signed in users can toggle star + Given I sign in as "John Doe" + And public project "Community" + And I visit project "Community" page + When I click on the star toggle button + Then The project has 1 star + When I click on the star toggle button + Then The project has 0 stars + + @javascript + Scenario: Star count sums stars + Given I sign in as "John Doe" + And public project "Community" + And I visit project "Community" page + And I click on the star toggle button + And I logout + And I sign in as "Mary Jane" + And I visit project "Community" page + When I click on the star toggle button + Then The project has 2 stars + + @javascript + Scenario: If an user deletes his account his stars are destroyed + Given I sign in as "John Doe" + And public project "Community" + And I visit project "Community" page + And I click on the star toggle button + And I delete my account + When I visit project "Community" page + Then The project has 0 stars diff --git a/features/steps/project/star.rb b/features/steps/project/star.rb new file mode 100644 index 00000000000..11102900ed4 --- /dev/null +++ b/features/steps/project/star.rb @@ -0,0 +1,29 @@ +class Spinach::Features::ProjectStar < Spinach::FeatureSteps + include SharedAuthentication + include SharedProject + include SharedPaths + include SharedUser + + step "The project has 0 stars" do + has_n_stars(0) + end + + step "The project has 1 star" do + has_n_stars(1) + end + + step "The project has 2 stars" do + has_n_stars(2) + end + + # Requires @javascript + step "I click on the star toggle button" do + page.find(".star .toggle", visible: true).click + end + + protected + + def has_n_stars(n) + expect(page).to have_css(".star .count", text: /^#{n}$/, visible: true) + end +end diff --git a/features/steps/public/projects.rb b/features/steps/public/projects.rb index 7c7311bb91c..f6ed838d2dc 100644 --- a/features/steps/public/projects.rb +++ b/features/steps/public/projects.rb @@ -3,10 +3,6 @@ class Spinach::Features::PublicProjectsFeature < Spinach::FeatureSteps include SharedPaths include SharedProject - step 'public empty project "Empty Public Project"' do - create :empty_project, :public, name: 'Empty Public Project' - end - step 'I should see project "Empty Public Project"' do page.should have_content "Empty Public Project" end @@ -20,16 +16,6 @@ class Spinach::Features::PublicProjectsFeature < Spinach::FeatureSteps page.should have_content 'README.md' end - step 'I visit empty project page' do - project = Project.find_by(name: 'Empty Public Project') - visit project_path(project) - end - - step 'I visit project "Community" page' do - project = Project.find_by(name: 'Community') - visit project_path(project) - end - step 'I should see empty public project details' do page.should have_content 'Git global setup' end @@ -48,22 +34,12 @@ class Spinach::Features::PublicProjectsFeature < Spinach::FeatureSteps end end - step 'I visit project "Enterprise" page' do - project = Project.find_by(name: 'Enterprise') - visit project_path(project) - end - step 'I should see project "Community" home page' do within '.project-home-title' do page.should have_content 'Community' end end - step 'I visit project "Internal" page' do - project = Project.find_by(name: 'Internal') - visit project_path(project) - end - step 'I should see project "Internal" home page' do within '.project-home-title' do page.should have_content 'Internal' diff --git a/features/steps/shared/authentication.rb b/features/steps/shared/authentication.rb index b8c11ce0a23..b48021dc146 100644 --- a/features/steps/shared/authentication.rb +++ b/features/steps/shared/authentication.rb @@ -24,6 +24,10 @@ module SharedAuthentication current_path.should == new_user_session_path end + step "I logout" do + logout + end + def current_user @user || User.first end diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb index 2090b642059..dc1f3eb64a0 100644 --- a/features/steps/shared/paths.rb +++ b/features/steps/shared/paths.rb @@ -320,6 +320,34 @@ module SharedPaths end # ---------------------------------------- + # Visibility Projects + # ---------------------------------------- + + step 'I visit project "Community" page' do + project = Project.find_by(name: "Community") + visit project_path(project) + end + + step 'I visit project "Internal" page' do + project = Project.find_by(name: "Internal") + visit project_path(project) + end + + step 'I visit project "Enterprise" page' do + project = Project.find_by(name: "Enterprise") + visit project_path(project) + end + + # ---------------------------------------- + # Empty Projects + # ---------------------------------------- + + step "I visit empty project page" do + project = Project.find_by(name: "Empty Public Project") + visit project_path(project) + end + + # ---------------------------------------- # Public Projects # ---------------------------------------- @@ -327,10 +355,6 @@ module SharedPaths visit public_root_path end - step 'I visit public page for "Community" project' do - visit public_project_path(Project.find_by(name: "Community")) - end - # ---------------------------------------- # Snippets # ---------------------------------------- diff --git a/features/steps/shared/project.rb b/features/steps/shared/project.rb index ddb87daeeb7..ba6f090a706 100644 --- a/features/steps/shared/project.rb +++ b/features/steps/shared/project.rb @@ -122,4 +122,12 @@ module SharedProject project ||= create :empty_project, :public, name: 'Community', namespace: user.namespace project.team << [user, :master] end + + # ---------------------------------------- + # Empty projects + # ---------------------------------------- + + step 'public empty project "Empty Public Project"' do + create :empty_project, :public, name: "Empty Public Project" + end end diff --git a/features/steps/shared/user.rb b/features/steps/shared/user.rb index 209d77c7acf..f52551c9dc7 100644 --- a/features/steps/shared/user.rb +++ b/features/steps/shared/user.rb @@ -9,6 +9,11 @@ module SharedUser user_exists("Mary Jane", {username: "mary_jane"}) end + step "I delete my account" do + visit profile_account_path + click_link "Delete account" + end + protected def user_exists(name, options = {}) |