Commit 192b08df authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'blackst0ne-replace-spinach-admin-push-rules.feature' into 'master'

Replace the `admin/push_rules.feature` spinach test with an rspec analog

See merge request gitlab-org/gitlab-ee!5512
parents 2c8acf86 43f69e05
---
title: 'Replace the `admin/push_rules.feature` spinach test with an rspec analog'
merge_request: 5512
author: "@blackst0ne"
type: other
require 'spec_helper' require "spec_helper"
describe "Admin::PushRules" do describe "Admin interacts with push rules" do
let(:current_user) { create(:admin) } set(:user) { create(:admin) }
before do before do
sign_in(current_user) sign_in(user)
end end
push_rules_with_titles = { push_rules_with_titles = {
reject_unsigned_commits: 'Reject unsigned commits', reject_unsigned_commits: "Reject unsigned commits",
commit_committer_check: 'Committer restriction' commit_committer_check: "Committer restriction"
} }
push_rules_with_titles.each do |rule_attr, title| push_rules_with_titles.each do |rule_attr, title|
context "when #{rule_attr} is unlicensed" do context "when #{rule_attr} is unlicensed" do
before do before do
stub_licensed_features(rule_attr => false) stub_licensed_features(rule_attr => false)
end
it 'does not render the setting checkbox' do
visit admin_push_rule_path
expect(page).not_to have_content(title) visit(admin_push_rule_path)
end end
it { expect(page).not_to have_content(title) }
end end
context "when #{rule_attr} is licensed" do context "when #{rule_attr} is licensed" do
before do before do
stub_licensed_features(rule_attr => true) stub_licensed_features(rule_attr => true)
visit(admin_push_rule_path)
end end
it 'renders the setting checkbox' do it { expect(page).to have_content(title) }
visit admin_push_rule_path end
end
expect(page).to have_content(title) context "when creating push rule" do
before do
visit(admin_push_rule_path)
end end
it "creates new rule" do
fill_in("Commit message", with: "my_string")
click_button("Save Push Rules")
expect(page).to have_selector("input[value='my_string']")
end end
end end
end end
@admin
Feature: Admin push rules sample
Background:
Given I sign in as an admin
And I visit push rules page
Scenario: I can create push rule sample
When I fill in a form and submit
Then I see my push rule saved
require 'webmock'
class Spinach::Features::AdminPushRulesSample < Spinach::FeatureSteps
include SharedAuthentication
include SharedProject
include SharedPaths
include RSpec::Matchers
include RSpec::Mocks::ExampleMethods
include WebMock::API
step 'I fill in a form and submit' do
fill_in "Commit message", with: "my_string"
click_button "Save Push Rules"
end
step 'I see my push rule saved' do
visit admin_push_rule_path
expect(page).to have_selector("input[value='my_string']")
end
end
...@@ -200,10 +200,6 @@ module SharedPaths ...@@ -200,10 +200,6 @@ module SharedPaths
visit admin_spam_logs_path visit admin_spam_logs_path
end end
step 'I visit push rules page' do
visit admin_push_rule_path
end
step 'I visit admin license page' do step 'I visit admin license page' do
visit admin_license_path visit admin_license_path
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment