summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2017-08-30 00:40:44 +0000
committerRobert Speicher <robert@gitlab.com>2017-08-30 00:40:44 +0000
commit499b640679c0dca5b5d93da945da0ca26db8e58e (patch)
treee33c22ed1b1d5c4b6dbc7dbaa1aa1231e03b65e4
parentcbaa015cc9f55a387cdab85a6ba4b8c9c6ab447e (diff)
parent569c7becf0ef18f56d03d738b8fedadbec869c08 (diff)
downloadgitlab-ce-499b640679c0dca5b5d93da945da0ca26db8e58e.tar.gz
Merge branch 'replace_spinach_star.feature' into 'master'
Replace 'project/star.feature' spinach test with an rspec analog See merge request !13855
-rw-r--r--changelogs/unreleased/replace_spinach_star-feature.yml5
-rw-r--r--features/project/star.feature39
-rw-r--r--features/steps/project/star.rb37
-rw-r--r--spec/features/projects/user_interacts_with_stars_spec.rb38
4 files changed, 43 insertions, 76 deletions
diff --git a/changelogs/unreleased/replace_spinach_star-feature.yml b/changelogs/unreleased/replace_spinach_star-feature.yml
new file mode 100644
index 00000000000..6a058691fe5
--- /dev/null
+++ b/changelogs/unreleased/replace_spinach_star-feature.yml
@@ -0,0 +1,5 @@
+---
+title: Replace 'project/star.feature' spinach test with an rspec analog
+merge_request: 13855
+author: Vitaliy @blackst0ne Klachkov
+type: other
diff --git a/features/project/star.feature b/features/project/star.feature
deleted file mode 100644
index 618f44fe6dc..00000000000
--- a/features/project/star.feature
+++ /dev/null
@@ -1,39 +0,0 @@
-@project-stars
-Feature: Project Star
- Scenario: New projects have 0 stars
- Given public project "Community"
- When I visit project "Community" page
- Then The project has no stars
-
- Scenario: Empty projects show star count
- Given public empty project "Empty Public Project"
- When I visit empty project page
- Then The project has no 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 I redirected to sign in page
-
- @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
diff --git a/features/steps/project/star.rb b/features/steps/project/star.rb
deleted file mode 100644
index 9f7c748a3b7..00000000000
--- a/features/steps/project/star.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-class Spinach::Features::ProjectStar < Spinach::FeatureSteps
- include SharedAuthentication
- include SharedProject
- include SharedPaths
- include SharedUser
-
- step "The project has no stars" do
- expect(page).not_to have_content '.toggle-star'
- end
-
- 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
- find(".star-btn", visible: true).click
- end
-
- step 'I redirected to sign in page' do
- expect(current_path).to eq new_user_session_path
- end
-
- protected
-
- def has_n_stars(n)
- expect(page).to have_css(".star-count", text: n, visible: true)
- end
-end
diff --git a/spec/features/projects/user_interacts_with_stars_spec.rb b/spec/features/projects/user_interacts_with_stars_spec.rb
new file mode 100644
index 00000000000..0ac3f8181fa
--- /dev/null
+++ b/spec/features/projects/user_interacts_with_stars_spec.rb
@@ -0,0 +1,38 @@
+require 'spec_helper'
+
+describe 'User interacts with project stars' do
+ let(:project) { create(:project, :public, :repository) }
+
+ context 'when user is signed in', js: true do
+ let(:user) { create(:user) }
+
+ before do
+ sign_in(user)
+ visit(project_path(project))
+ end
+
+ it 'toggles the star' do
+ find('.star-btn').click
+
+ expect(page).to have_css('.star-count', text: 1)
+
+ find('.star-btn').click
+
+ expect(page).to have_css('.star-count', text: 0)
+ end
+ end
+
+ context 'when user is not signed in' do
+ before do
+ visit(project_path(project))
+ end
+
+ it 'does not allow to star a project' do
+ expect(page).not_to have_content('.toggle-star')
+
+ find('.star-btn').click
+
+ expect(current_path).to eq(new_user_session_path)
+ end
+ end
+end