diff options
Diffstat (limited to 'spec/support/shared_examples/lib')
4 files changed, 34 insertions, 5 deletions
diff --git a/spec/support/shared_examples/lib/gitlab/event_store_shared_examples.rb b/spec/support/shared_examples/lib/gitlab/event_store_shared_examples.rb new file mode 100644 index 00000000000..4fc15cacab4 --- /dev/null +++ b/spec/support/shared_examples/lib/gitlab/event_store_shared_examples.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +RSpec.shared_examples 'subscribes to event' do + include AfterNextHelpers + + it 'consumes the published event', :sidekiq_inline do + expect_next(described_class) + .to receive(:handle_event) + .with(instance_of(event.class)) + .and_call_original + + ::Gitlab::EventStore.publish(event) + end +end + +def consume_event(subscriber:, event:) + subscriber.new.perform(event.class.name, event.data) +end diff --git a/spec/support/shared_examples/lib/gitlab/usage_data_counters/issuable_activity_shared_examples.rb b/spec/support/shared_examples/lib/gitlab/usage_data_counters/issuable_activity_shared_examples.rb index 4b956c2b566..b5d93aec1bf 100644 --- a/spec/support/shared_examples/lib/gitlab/usage_data_counters/issuable_activity_shared_examples.rb +++ b/spec/support/shared_examples/lib/gitlab/usage_data_counters/issuable_activity_shared_examples.rb @@ -5,7 +5,7 @@ RSpec.shared_examples 'a daily tracked issuable event' do stub_application_setting(usage_ping_enabled: true) end - def count_unique(date_from:, date_to:) + def count_unique(date_from: 1.minute.ago, date_to: 1.minute.from_now) Gitlab::UsageDataCounters::HLLRedisCounter.unique_events(event_names: action, start_date: date_from, end_date: date_to) end @@ -14,6 +14,7 @@ RSpec.shared_examples 'a daily tracked issuable event' do expect(track_action(author: user1)).to be_truthy expect(track_action(author: user1)).to be_truthy expect(track_action(author: user2)).to be_truthy + expect(count_unique).to eq(2) end end diff --git a/spec/support/shared_examples/lib/sidebars/projects/menus/zentao_menu_shared_examples.rb b/spec/support/shared_examples/lib/sidebars/projects/menus/zentao_menu_shared_examples.rb index b4c438771ce..d816754f328 100644 --- a/spec/support/shared_examples/lib/sidebars/projects/menus/zentao_menu_shared_examples.rb +++ b/spec/support/shared_examples/lib/sidebars/projects/menus/zentao_menu_shared_examples.rb @@ -34,8 +34,16 @@ RSpec.shared_examples 'ZenTao menu with CE version' do expect(subject.link).to eq zentao_integration.url end - it 'contains only open ZenTao item' do - expect(subject.renderable_items.map(&:item_id)).to match_array [:open_zentao] + it 'renders external-link icon' do + expect(subject.sprite_icon).to eq 'external-link' + end + + it 'renders ZenTao menu' do + expect(subject.title).to eq s_('ZentaoIntegration|ZenTao') + end + + it 'does not contain items' do + expect(subject.renderable_items.count).to eq 0 end end end diff --git a/spec/support/shared_examples/lib/wikis_api_examples.rb b/spec/support/shared_examples/lib/wikis_api_examples.rb index f068a7676ad..c57ac328a60 100644 --- a/spec/support/shared_examples/lib/wikis_api_examples.rb +++ b/spec/support/shared_examples/lib/wikis_api_examples.rb @@ -80,6 +80,8 @@ RSpec.shared_examples_for 'wikis API returns wiki page' do context 'when wiki page has versions' do let(:new_content) { 'New content' } + let(:old_content) { page.content } + let(:old_version_id) { page.version.id } before do wiki.update_page(page.page, content: new_content, message: 'updated page') @@ -96,10 +98,10 @@ RSpec.shared_examples_for 'wikis API returns wiki page' do end context 'when version param is set' do - let(:params) { { version: page.version.id } } + let(:params) { { version: old_version_id } } it 'retrieves the specific page version' do - expect(json_response['content']).to eq(page.content) + expect(json_response['content']).to eq(old_content) end context 'when version param is not valid or inexistent' do |