Skip to content
Snippets Groups Projects
Commit c2c49808 authored by Dylan Griffith's avatar Dylan Griffith
Browse files

Add #to_ability_name to Project & Milestone

This will be used later for search filtering.
parent 3a4876ff
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -254,6 +254,10 @@ class Milestone < ApplicationRecord
group || project
end
 
def to_ability_name
model_name.singular
end
def group_milestone?
group_id.present?
end
Loading
Loading
Loading
Loading
@@ -1223,6 +1223,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
Loading
Loading
Loading
Loading
@@ -206,6 +206,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') }
 
Loading
Loading
Loading
Loading
@@ -4334,6 +4334,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
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment