Commit e4363d48 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'display-correct-push-rule-in-form' into 'master'

Display project push rule in form instead of sample push rule

Closes #1924

See merge request !1476
parents ebbe1879 12db6a74
......@@ -8,12 +8,6 @@ class Projects::PushRulesController < Projects::ApplicationController
layout "project_settings"
def index
project.create_push_rule unless project.push_rule
@push_rule = project.push_rule
end
def update
@push_rule = project.push_rule
@push_rule.update_attributes(push_rule_params)
......
......@@ -2,7 +2,6 @@ module Projects
module Settings
class RepositoryController < Projects::ApplicationController
before_action :authorize_admin_project!
before_action :push_rule, only: [:show]
before_action :remote_mirror, only: [:show]
def show
......@@ -10,6 +9,9 @@ module Projects
.new(@project, current_user: current_user)
define_protected_branches
project.create_push_rule unless project.push_rule
@push_rule = project.push_rule
end
private
......@@ -20,10 +22,6 @@ module Projects
load_gon_index
end
def push_rule
@push_rule ||= PushRule.find_or_create_by(is_sample: true)
end
def remote_mirror
@remote_mirror = @project.remote_mirrors.first_or_initialize
end
......
Feature: Push Rules
Background:
Given I sign in as a user
And I own project "Shop"
Scenario: I should see push rule form
When I visit project push rules page
Then I should see push rule form
require 'webmock'
class Spinach::Features::PushRules < Spinach::FeatureSteps
include SharedAuthentication
include SharedProject
include SharedPaths
include RSpec::Matchers
include RSpec::Mocks::ExampleMethods
include WebMock::API
step 'I should see push rule form' do
expect(page).to have_selector('input#push_rule_commit_message_regex')
expect(page).to have_content "Commit message"
expect(page).to have_content "Commit author's email"
end
end
......@@ -283,10 +283,6 @@ module SharedPaths
visit group_hooks_path(@group)
end
step 'I visit project push rules page' do
visit namespace_project_settings_repository_path(@project.namespace, @project)
end
step 'I visit project deploy keys page' do
visit namespace_project_deploy_keys_path(@project.namespace, @project)
end
......
require 'spec_helper'
describe 'Project settings > [EE] Push Rules', feature: true do
let(:user) { create(:user) }
let(:project) { create(:project_empty_repo) }
before do
project.team << [user, :master]
login_as(user)
end
describe 'editing a push rule' do
let(:commit_message) { 'Required part of every message' }
let(:input_id) { 'push_rule_commit_message_regex' }
before do
visit namespace_project_settings_repository_path(project.namespace, project)
fill_in input_id, with: commit_message
click_button 'Save Push Rules'
end
it 'displays the new value in the form' do
expect(find("##{input_id}").value).to eq commit_message
end
it 'saves the new value' do
expect(project.push_rule.commit_message_regex).to eq commit_message
end
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