diff options
Diffstat (limited to 'spec/models/concerns')
-rw-r--r-- | spec/models/concerns/issuable_spec.rb | 16 | ||||
-rw-r--r-- | spec/models/concerns/participable_spec.rb | 25 | ||||
-rw-r--r-- | spec/models/concerns/routable_spec.rb | 33 | ||||
-rw-r--r-- | spec/models/concerns/triggerable_hooks_spec.rb | 2 |
4 files changed, 33 insertions, 43 deletions
diff --git a/spec/models/concerns/issuable_spec.rb b/spec/models/concerns/issuable_spec.rb index 2a3f639a8ac..e9c3d1dc646 100644 --- a/spec/models/concerns/issuable_spec.rb +++ b/spec/models/concerns/issuable_spec.rb @@ -922,6 +922,22 @@ RSpec.describe Issuable do end end + describe '#supports_escalation?' do + where(:issuable_type, :supports_escalation) do + :issue | false + :incident | true + :merge_request | false + end + + with_them do + let(:issuable) { build_stubbed(issuable_type) } + + subject { issuable.supports_escalation? } + + it { is_expected.to eq(supports_escalation) } + end + end + describe '#incident?' do where(:issuable_type, :incident) do :issue | false diff --git a/spec/models/concerns/participable_spec.rb b/spec/models/concerns/participable_spec.rb index 50cf7377b99..99a3a0fb79a 100644 --- a/spec/models/concerns/participable_spec.rb +++ b/spec/models/concerns/participable_spec.rb @@ -138,7 +138,7 @@ RSpec.describe Participable do allow(instance).to receive_message_chain(:model_name, :element) { 'class' } expect(instance).to receive(:foo).and_return(user2) expect(instance).to receive(:bar).and_return(user3) - expect(instance).to receive(:project).thrice.and_return(project) + expect(instance).to receive(:project).twice.and_return(project) participants = instance.visible_participants(user1) @@ -159,31 +159,10 @@ RSpec.describe Participable do allow(instance).to receive_message_chain(:model_name, :element) { 'class' } allow(instance).to receive(:bar).and_return(user2) - expect(instance).to receive(:project).thrice.and_return(project) + expect(instance).to receive(:project).twice.and_return(project) expect(instance.visible_participants(user1)).to be_empty end - - context 'when feature flag is disabled' do - before do - stub_feature_flags(verify_participants_access: false) - end - - it 'returns unavailable participants' do - model.participant(:bar) - - instance = model.new - user1 = build(:user) - user2 = build(:user) - project = build(:project, :public) - - allow(instance).to receive_message_chain(:model_name, :element) { 'class' } - allow(instance).to receive(:bar).and_return(user2) - expect(instance).to receive(:project).thrice.and_return(project) - - expect(instance.visible_participants(user1)).to match_array([user2]) - end - end end end diff --git a/spec/models/concerns/routable_spec.rb b/spec/models/concerns/routable_spec.rb index 2330147b376..cf66ba83e87 100644 --- a/spec/models/concerns/routable_spec.rb +++ b/spec/models/concerns/routable_spec.rb @@ -141,6 +141,11 @@ RSpec.describe Group, 'Routable', :with_clean_rails_cache do end end + it 'creates route with namespace referencing group' do + expect(group.route).not_to be_nil + expect(group.route.namespace).to eq(group) + end + describe '.where_full_path_in' do context 'without any paths' do it 'returns an empty relation' do @@ -208,30 +213,20 @@ RSpec.describe Project, 'Routable', :with_clean_rails_cache do it_behaves_like 'routable resource with parent' do let_it_be(:record) { project } end + + it 'creates route with namespace referencing project namespace' do + expect(project.route).not_to be_nil + expect(project.route.namespace).to eq(project.project_namespace) + end end RSpec.describe Namespaces::ProjectNamespace, 'Routable', :with_clean_rails_cache do let_it_be(:group) { create(:group) } - let_it_be(:project_namespace) do - # For now we create only project namespace w/o project, otherwise same path - # would be used for project and project namespace. - # This can be removed when route is created automatically for project namespaces. - # https://gitlab.com/gitlab-org/gitlab/-/issues/346448 - create(:project_namespace, project: nil, parent: group, - visibility_level: Gitlab::VisibilityLevel::PUBLIC, - path: 'foo', name: 'foo').tap do |project_namespace| - Route.create!(source: project_namespace, path: project_namespace.full_path, - name: project_namespace.full_name) - end - end - - # we have couple of places where we use generic Namespace, in that case - # we don't want to include ProjectNamespace routes yet - it 'ignores project namespace when searching for generic namespace' do - redirect_route = create(:redirect_route, source: project_namespace) - expect(Namespace.find_by_full_path(project_namespace.full_path)).to be_nil - expect(Namespace.find_by_full_path(redirect_route.path, follow_redirects: true)).to be_nil + it 'skips route creation for the resource' do + expect do + described_class.create!(project: nil, parent: group, visibility_level: Gitlab::VisibilityLevel::PUBLIC, path: 'foo', name: 'foo') + end.not_to change { Route.count } end end diff --git a/spec/models/concerns/triggerable_hooks_spec.rb b/spec/models/concerns/triggerable_hooks_spec.rb index 10a6c1aa821..90c88c888ff 100644 --- a/spec/models/concerns/triggerable_hooks_spec.rb +++ b/spec/models/concerns/triggerable_hooks_spec.rb @@ -46,7 +46,7 @@ RSpec.describe TriggerableHooks do describe '.select_active' do it 'returns hooks that match the active filter' do TestableHook.create!(url: 'http://example1.com', push_events: true) - TestableHook.create!(url: 'http://example2.com', push_events: true) + TestableHook.create!(url: 'http://example.org', push_events: true) filter1 = double(:filter1) filter2 = double(:filter2) allow(ActiveHookFilter).to receive(:new).twice.and_return(filter1, filter2) |