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
let(:current_user) { create(:admin) }
describe "Admin interacts with push rules" do
set(:user) { create(:admin) }
before do
sign_in(current_user)
sign_in(user)
end
push_rules_with_titles = {
reject_unsigned_commits: 'Reject unsigned commits',
commit_committer_check: 'Committer restriction'
reject_unsigned_commits: "Reject unsigned commits",
commit_committer_check: "Committer restriction"
}
push_rules_with_titles.each do |rule_attr, title|
context "when #{rule_attr} is unlicensed" do
before do
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
it { expect(page).not_to have_content(title) }
end
context "when #{rule_attr} is licensed" do
before do
stub_licensed_features(rule_attr => true)
visit(admin_push_rule_path)
end
it 'renders the setting checkbox' do
visit admin_push_rule_path
it { expect(page).to have_content(title) }
end
end
context "when creating push rule" do
before do
visit(admin_push_rule_path)
end
expect(page).to have_content(title)
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
@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
visit admin_spam_logs_path
end
step 'I visit push rules page' do
visit admin_push_rule_path
end
step 'I visit admin license page' do
visit admin_license_path
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