Commit f8a130b1 authored by Dylan Griffith's avatar Dylan Griffith

Add #to_ability_name to Project & Milestone

This will be used later for search filtering.
parent ba8b47a7
......@@ -261,6 +261,10 @@ class Milestone < ApplicationRecord
group || project
end
def to_ability_name
model_name.singular
end
def group_milestone?
group_id.present?
end
......
......@@ -1260,6 +1260,10 @@ class Project < ApplicationRecord
end
end
def to_ability_name
model_name.singular
end
# rubocop: disable CodeReuse/ServiceClass
def execute_hooks(data, hooks_scope = :push_hooks)
run_after_commit_or_now do
......
......@@ -227,6 +227,14 @@ describe Milestone do
end
end
describe '#to_ability_name' do
it 'returns milestone' do
milestone = build(:milestone)
expect(milestone.to_ability_name).to eq('milestone')
end
end
describe '.search' do
let(:milestone) { create(:milestone, title: 'foo', description: 'bar') }
......
......@@ -4441,6 +4441,14 @@ describe Project do
end
end
describe '#to_ability_name' do
it 'returns project' do
project = build(:project_empty_repo)
expect(project.to_ability_name).to eq('project')
end
end
describe '#execute_hooks' do
let(:data) { { ref: 'refs/heads/master', data: 'data' } }
it 'executes active projects hooks with the specified scope' 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