Commit bc3603cf authored by Arturo Herrero's avatar Arturo Herrero

Remove Service#template? method

This is a boolean column so we can remove this method. Rails defined
automatically #{attribute}? methods.
parent 6999eb9d
......@@ -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