Commit f1bfe1ac authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'remove-service-template' into 'master'

Remove Service#template?

See merge request gitlab-org/gitlab!25979
parents 37f82d6b bc3603cf
......@@ -32,7 +32,7 @@ class Service < ApplicationRecord
belongs_to :project, inverse_of: :services
has_one :service_hook
validates :project_id, presence: true, unless: proc { |service| service.template? }
validates :project_id, presence: true, unless: -> { template? }
validates :type, presence: true
scope :visible, -> { where.not(type: 'GitlabIssueTrackerService') }
......@@ -70,10 +70,6 @@ class Service < ApplicationRecord
true
end
def template?
template
end
def category
read_attribute(:category).to_sym
end
......
......@@ -10,8 +10,13 @@ describe Service do
it { is_expected.to have_one :issue_tracker_data }
end
describe 'Validations' do
describe 'validations' do
it { is_expected.to validate_presence_of(:type) }
it 'validates presence of project_id if not template', :aggregate_failures do
expect(build(:service, project_id: nil, template: true)).to be_valid
expect(build(:service, project_id: nil, template: false)).to be_invalid
end
end
describe 'Scopes' do
......
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