diff options
author | Robert Speicher <rspeicher@gmail.com> | 2014-03-19 13:15:24 +0400 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2014-03-19 13:15:24 +0400 |
commit | 1897fb00b8d804cffa40da074f83575489beddb0 (patch) | |
tree | 8492bd315ba3229feef426406cfd6b45a60392cf /spec/services/search_service_spec.rb | |
parent | 65d634706cf833fc4b0b2f263f9d8fb35219858e (diff) |
Make use of project factory traits
Diffstat (limited to 'spec/services/search_service_spec.rb')
-rw-r--r-- | spec/services/search_service_spec.rb | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/spec/services/search_service_spec.rb b/spec/services/search_service_spec.rb index 457cb3c0ca3..b467282a5d6 100644 --- a/spec/services/search_service_spec.rb +++ b/spec/services/search_service_spec.rb @@ -1,28 +1,26 @@ require 'spec_helper' describe 'Search::GlobalService' do - let(:found_namespace) { create(:namespace, name: 'searchable namespace', path:'another_thing') } let(:user) { create(:user, namespace: found_namespace) } - let!(:found_project) { create(:project, name: 'searchable_project', creator_id: user.id, namespace: found_namespace, visibility_level: Gitlab::VisibilityLevel::PRIVATE) } + let(:public_user) { create(:user, namespace: public_namespace) } + let(:internal_user) { create(:user, namespace: internal_namespace) } + let(:found_namespace) { create(:namespace, name: 'searchable namespace', path:'another_thing') } let(:unfound_namespace) { create(:namespace, name: 'unfound namespace', path: 'yet_something_else') } - let!(:unfound_project) { create(:project, name: 'unfound_project', creator_id: user.id, namespace: unfound_namespace, visibility_level: Gitlab::VisibilityLevel::PRIVATE) } + let(:internal_namespace) { create(:namespace, name: 'searchable internal namespace', path: 'something_internal') } + let(:public_namespace) { create(:namespace, name: 'searchable public namespace', path: 'something_public') } - let(:internal_namespace) { create(:namespace, path: 'something_internal',name: 'searchable internal namespace') } - let(:internal_user) { create(:user, namespace: internal_namespace) } - let!(:internal_project) { create(:project, name: 'searchable_internal_project', creator_id: internal_user.id, namespace: internal_namespace, visibility_level: Gitlab::VisibilityLevel::INTERNAL) } - - let(:public_namespace) { create(:namespace, path: 'something_public',name: 'searchable public namespace') } - let(:public_user) { create(:user, namespace: public_namespace) } - let!(:public_project) { create(:project, name: 'searchable_public_project', creator_id: public_user.id, namespace: public_namespace, visibility_level: Gitlab::VisibilityLevel::PUBLIC) } + let!(:found_project) { create(:project, :private, name: 'searchable_project', creator_id: user.id, namespace: found_namespace) } + let!(:unfound_project) { create(:project, :private, name: 'unfound_project', creator_id: user.id, namespace: unfound_namespace) } + let!(:internal_project) { create(:project, :internal, name: 'searchable_internal_project', creator_id: internal_user.id, namespace: internal_namespace) } + let!(:public_project) { create(:project, :public, name: 'searchable_public_project', creator_id: public_user.id, namespace: public_namespace) } describe '#execute' do context 'unauthenticated' do it 'should return public projects only' do context = Search::GlobalService.new(nil, search: "searchable") results = context.execute - results[:projects].should have(1).items - results[:projects].should include(public_project) + results[:projects].should match_array [public_project] end end @@ -30,24 +28,19 @@ describe 'Search::GlobalService' do it 'should return public, internal and private projects' do context = Search::GlobalService.new(user, search: "searchable") results = context.execute - results[:projects].should have(3).items - results[:projects].should include(public_project) - results[:projects].should include(found_project) - results[:projects].should include(internal_project) + results[:projects].should match_array [public_project, found_project, internal_project] end it 'should return only public & internal projects' do context = Search::GlobalService.new(internal_user, search: "searchable") results = context.execute - results[:projects].should have(2).items - results[:projects].should include(internal_project) - results[:projects].should include(public_project) + results[:projects].should match_array [internal_project, public_project] end it 'namespace name should be searchable' do context = Search::GlobalService.new(user, search: "searchable namespace") results = context.execute - results[:projects].should == [found_project] + results[:projects].should match_array [found_project] end end end |