diff options
author | Duana Saskia <starkcoffee@users.noreply.github.com> | 2018-09-01 18:55:06 +0300 |
---|---|---|
committer | Duana Saskia <starkcoffee@users.noreply.github.com> | 2018-09-05 14:58:52 +0300 |
commit | 9d742e61a79dcc85589598259e2fdac030b7ac00 (patch) | |
tree | b1f0b422eeebbc98a52d2003e7ead78fb504afd6 /spec/models/project_spec.rb | |
parent | c322976032e45f02b60701ebf244a8a876063078 (diff) |
Refactor: move active hook filter to TriggerableHooks
Diffstat (limited to 'spec/models/project_spec.rb')
-rw-r--r-- | spec/models/project_spec.rb | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index cea7fa31b16..d3dc95548aa 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -3672,36 +3672,36 @@ describe Project do describe '#execute_hooks' do let(:data) { { ref: 'refs/heads/master', data: 'data' } } it 'executes active projects hooks with the specified scope' do - expect_any_instance_of(ActiveHookFilter).to receive(:matches?) - .with(:tag_push_hooks, data) - .and_return(true) - hook = create(:project_hook, merge_requests_events: false, tag_push_events: true) + hook = create(:project_hook, merge_requests_events: false, push_events: true) + expect(ProjectHook).to receive(:select_active) + .with(:push_hooks, data) + .and_return([hook]) project = create(:project, hooks: [hook]) expect_any_instance_of(ProjectHook).to receive(:async_execute).once - project.execute_hooks(data, :tag_push_hooks) + project.execute_hooks(data, :push_hooks) end it 'does not execute project hooks that dont match the specified scope' do - hook = create(:project_hook, merge_requests_events: true, tag_push_events: false) + hook = create(:project_hook, merge_requests_events: true, push_events: false) project = create(:project, hooks: [hook]) expect_any_instance_of(ProjectHook).not_to receive(:async_execute).once - project.execute_hooks(data, :tag_push_hooks) + project.execute_hooks(data, :push_hooks) end it 'does not execute project hooks which are not active' do - expect_any_instance_of(ActiveHookFilter).to receive(:matches?) - .with(:tag_push_hooks, data) - .and_return(false) - hook = create(:project_hook, tag_push_events: true) + hook = create(:project_hook, push_events: true) + expect(ProjectHook).to receive(:select_active) + .with(:push_hooks, data) + .and_return([]) project = create(:project, hooks: [hook]) expect_any_instance_of(ProjectHook).not_to receive(:async_execute).once - project.execute_hooks(data, :tag_push_hooks) + project.execute_hooks(data, :push_hooks) end it 'executes the system hooks with the specified scope' do |