summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2018-05-09 23:07:23 +0000
committerRobert Speicher <robert@gitlab.com>2018-05-09 23:07:23 +0000
commitf4c36fac60e56ec3e50bb08581b5fababa05c693 (patch)
tree2c35695da1abcfccf12eb6a922643005a7e4375c
parent1a9f90f8c132feb5760720931597e1bff28d386d (diff)
parent3b21da84052738ed6114401fe363cf4b98a57030 (diff)
downloadgitlab-ce-f4c36fac60e56ec3e50bb08581b5fababa05c693.tar.gz
Merge branch 'blackst0ne-replace-spinach-project-deploy-keys.feature' into 'master'
Replace the `project/deploy_keys.feature` spinach test with an rspec analog See merge request gitlab-org/gitlab-ce!18796
-rw-r--r--changelogs/unreleased/blackst0ne-replace-spinach-project-deploy-keys-feature.yml5
-rw-r--r--features/project/deploy_keys.feature46
-rw-r--r--features/steps/project/deploy_keys.rb94
-rw-r--r--features/steps/shared/paths.rb4
-rw-r--r--spec/features/projects/settings/user_interacts_with_deploy_keys_spec.rb125
5 files changed, 130 insertions, 144 deletions
diff --git a/changelogs/unreleased/blackst0ne-replace-spinach-project-deploy-keys-feature.yml b/changelogs/unreleased/blackst0ne-replace-spinach-project-deploy-keys-feature.yml
new file mode 100644
index 00000000000..7014de4ece7
--- /dev/null
+++ b/changelogs/unreleased/blackst0ne-replace-spinach-project-deploy-keys-feature.yml
@@ -0,0 +1,5 @@
+---
+title: 'Replace the `project/deploy_keys.feature` spinach test with an rspec analog'
+merge_request: 18796
+author: '@blackst0ne'
+type: other
diff --git a/features/project/deploy_keys.feature b/features/project/deploy_keys.feature
deleted file mode 100644
index 6f1ed9ff5b6..00000000000
--- a/features/project/deploy_keys.feature
+++ /dev/null
@@ -1,46 +0,0 @@
-Feature: Project Deploy Keys
- Background:
- Given I sign in as a user
- And I own project "Shop"
-
- @javascript
- Scenario: I should see deploy keys list
- Given project has deploy key
- When I visit project deploy keys page
- Then I should see project deploy key
-
- @javascript
- Scenario: I should see project deploy keys
- Given other projects have deploy keys
- When I visit project deploy keys page
- Then I should see other project deploy key
- And I should only see the same deploy key once
-
- @javascript
- Scenario: I should see public deploy keys
- Given public deploy key exists
- When I visit project deploy keys page
- Then I should see public deploy key
-
- @javascript
- Scenario: I add new deploy key
- Given I visit project deploy keys page
- And I submit new deploy key
- Then I should be on deploy keys page
- And I should see newly created deploy key
-
- @javascript
- Scenario: I attach other project deploy key to project
- Given other projects have deploy keys
- And I visit project deploy keys page
- When I click attach deploy key
- Then I should be on deploy keys page
- And I should see newly created deploy key
-
- @javascript
- Scenario: I attach public deploy key to project
- Given public deploy key exists
- And I visit project deploy keys page
- When I click attach deploy key
- Then I should be on deploy keys page
- And I should see newly created deploy key
diff --git a/features/steps/project/deploy_keys.rb b/features/steps/project/deploy_keys.rb
deleted file mode 100644
index 8e2f594328d..00000000000
--- a/features/steps/project/deploy_keys.rb
+++ /dev/null
@@ -1,94 +0,0 @@
-class Spinach::Features::ProjectDeployKeys < Spinach::FeatureSteps
- include SharedAuthentication
- include SharedProject
- include SharedPaths
-
- step 'project has deploy key' do
- create(:deploy_keys_project, project: @project)
- end
-
- step 'I should see project deploy key' do
- page.within(find('.deploy-keys')) do
- find('.js-deployKeys-tab-enabled_keys').click()
- expect(page).to have_content deploy_key.title
- end
- end
-
- step 'I should see other project deploy key' do
- page.within(find('.deploy-keys')) do
- find('.js-deployKeys-tab-available_project_keys').click()
- expect(page).to have_content other_deploy_key.title
- end
- end
-
- step 'I should see public deploy key' do
- page.within(find('.deploy-keys')) do
- find('.js-deployKeys-tab-public_keys').click()
- expect(page).to have_content public_deploy_key.title
- end
- end
-
- step 'I click \'New Deploy Key\'' do
- click_link 'New deploy key'
- end
-
- step 'I submit new deploy key' do
- fill_in "deploy_key_title", with: "laptop"
- fill_in "deploy_key_key", with: "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAzrEJUIR6Y03TCE9rIJ+GqTBvgb8t1jI9h5UBzCLuK4VawOmkLornPqLDrGbm6tcwM/wBrrLvVOqi2HwmkKEIecVO0a64A4rIYScVsXIniHRS6w5twyn1MD3sIbN+socBDcaldECQa2u1dI3tnNVcs8wi77fiRe7RSxePsJceGoheRQgC8AZ510UdIlO+9rjIHUdVN7LLyz512auAfYsgx1OfablkQ/XJcdEwDNgi9imI6nAXhmoKUm1IPLT2yKajTIC64AjLOnE0YyCh6+7RFMpiMyu1qiOCpdjYwTgBRiciNRZCH8xIedyCoAmiUgkUT40XYHwLuwiPJICpkAzp7Q== user@laptop"
- click_button "Add key"
- end
-
- step 'I should be on deploy keys page' do
- expect(current_path).to eq project_settings_repository_path(@project)
- end
-
- step 'I should see newly created deploy key' do
- @project.reload
- page.within(find('.deploy-keys')) do
- find('.js-deployKeys-tab-enabled_keys').click()
- expect(page).to have_content(deploy_key.title)
- end
- end
-
- step 'other projects have deploy keys' do
- @second_project = create(:project, namespace: create(:group))
- @second_project.add_master(current_user)
- create(:deploy_keys_project, project: @second_project)
-
- @third_project = create(:project, namespace: create(:group))
- @third_project.add_master(current_user)
- create(:deploy_keys_project, project: @third_project, deploy_key: @second_project.deploy_keys.first)
- end
-
- step 'I should only see the same deploy key once' do
- page.within(find('.deploy-keys')) do
- expect(find('.js-deployKeys-tab-available_project_keys .badge')).to have_content('1')
- end
- end
-
- step 'public deploy key exists' do
- create(:deploy_key, public: true)
- end
-
- step 'I click attach deploy key' do
- page.within(find('.deploy-keys')) do
- find('.badge', text: '1').click()
- click_button 'Enable'
- expect(page).not_to have_selector('.fa-spinner')
- end
- end
-
- protected
-
- def deploy_key
- @project.deploy_keys.last
- end
-
- def other_deploy_key
- @second_project.deploy_keys.last
- end
-
- def public_deploy_key
- DeployKey.are_public.last
- end
-end
diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb
index f2769f28fed..a6bf7008955 100644
--- a/features/steps/shared/paths.rb
+++ b/features/steps/shared/paths.rb
@@ -240,10 +240,6 @@ module SharedPaths
visit project_settings_integrations_path(@project)
end
- step 'I visit project deploy keys page' do
- visit project_deploy_keys_path(@project)
- end
-
step 'I visit project find file page' do
visit project_find_file_path(@project, root_ref)
end
diff --git a/spec/features/projects/settings/user_interacts_with_deploy_keys_spec.rb b/spec/features/projects/settings/user_interacts_with_deploy_keys_spec.rb
new file mode 100644
index 00000000000..71a077039b7
--- /dev/null
+++ b/spec/features/projects/settings/user_interacts_with_deploy_keys_spec.rb
@@ -0,0 +1,125 @@
+require "spec_helper"
+
+describe "User interacts with deploy keys", :js do
+ let(:project) { create(:project, :repository) }
+ let(:user) { project.owner }
+
+ before do
+ sign_in(user)
+ end
+
+ shared_examples "attaches a key" do
+ it "attaches key" do
+ visit(project_deploy_keys_path(project))
+
+ page.within(".deploy-keys") do
+ find(".badge", text: "1").click
+
+ click_button("Enable")
+
+ expect(page).not_to have_selector(".fa-spinner")
+ expect(current_path).to eq(project_settings_repository_path(project))
+
+ find(".js-deployKeys-tab-enabled_keys").click
+
+ expect(page).to have_content(deploy_key.title)
+ end
+ end
+ end
+
+ context "viewing deploy keys" do
+ let(:deploy_key) { create(:deploy_key) }
+
+ context "when project has keys" do
+ before do
+ create(:deploy_keys_project, project: project, deploy_key: deploy_key)
+ end
+
+ it "shows deploy keys" do
+ visit(project_deploy_keys_path(project))
+
+ page.within(".deploy-keys") do
+ expect(page).to have_content(deploy_key.title)
+ end
+ end
+ end
+
+ context "when another project has keys" do
+ let(:another_project) { create(:project) }
+
+ before do
+ create(:deploy_keys_project, project: another_project, deploy_key: deploy_key)
+
+ another_project.add_master(user)
+ end
+
+ it "shows deploy keys" do
+ visit(project_deploy_keys_path(project))
+
+ page.within(".deploy-keys") do
+ find('.js-deployKeys-tab-available_project_keys').click
+
+ expect(page).to have_content(deploy_key.title)
+ expect(find(".js-deployKeys-tab-available_project_keys .badge")).to have_content("1")
+ end
+ end
+ end
+
+ context "when there are public deploy keys" do
+ let!(:deploy_key) { create(:deploy_key, public: true) }
+
+ it "shows public deploy keys" do
+ visit(project_deploy_keys_path(project))
+
+ page.within(".deploy-keys") do
+ find(".js-deployKeys-tab-public_keys").click
+
+ expect(page).to have_content(deploy_key.title)
+ end
+ end
+ end
+ end
+
+ context "adding deploy keys" do
+ before do
+ visit(project_deploy_keys_path(project))
+ end
+
+ it "adds new key" do
+ DEPLOY_KEY_TITLE = attributes_for(:key)[:title]
+ DEPLOY_KEY_BODY = attributes_for(:key)[:key]
+
+ fill_in("deploy_key_title", with: DEPLOY_KEY_TITLE)
+ fill_in("deploy_key_key", with: DEPLOY_KEY_BODY)
+
+ click_button("Add key")
+
+ expect(current_path).to eq(project_settings_repository_path(project))
+
+ page.within(".deploy-keys") do
+ expect(page).to have_content(DEPLOY_KEY_TITLE)
+ end
+ end
+ end
+
+ context "attaching existing keys" do
+ context "from another project" do
+ let(:another_project) { create(:project) }
+ let(:deploy_key) { create(:deploy_key) }
+
+ before do
+ create(:deploy_keys_project, project: another_project, deploy_key: deploy_key)
+
+ another_project.add_master(user)
+ end
+
+ it_behaves_like "attaches a key"
+ end
+
+ context "when keys are public" do
+ let!(:deploy_key) { create(:deploy_key, public: true) }
+
+ it_behaves_like "attaches a key"
+ end
+ end
+end