From 4a1654ed6a2393279ba6227454acbc3a80559d7d Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 16 Jan 2014 20:29:18 +0200 Subject: [PATCH] Replace context with service in specs Signed-off-by: Dmitriy Zaporozhets --- spec/models/forked_project_link_spec.rb | 2 +- .../fork_service_spec.rb} | 4 ++-- .../issues/bulk_update_context_spec.rb | 12 ++++++------ .../projects_create_service_spec.rb} | 4 ++-- .../projects_update_service_spec.rb} | 6 +++--- .../search_service_spec.rb} | 10 +++++----- 6 files changed, 19 insertions(+), 19 deletions(-) rename spec/{contexts/fork_context_spec.rb => services/fork_service_spec.rb} (94%) rename spec/{contexts => services}/issues/bulk_update_context_spec.rb (85%) rename spec/{contexts/projects_create_context_spec.rb => services/projects_create_service_spec.rb} (98%) rename spec/{contexts/projects_update_context_spec.rb => services/projects_update_service_spec.rb} (97%) rename spec/{contexts/search_context_spec.rb => services/search_service_spec.rb} (89%) diff --git a/spec/models/forked_project_link_spec.rb b/spec/models/forked_project_link_spec.rb index 472ddf1b59d..e719e3bfcc8 100644 --- a/spec/models/forked_project_link_spec.rb +++ b/spec/models/forked_project_link_spec.rb @@ -58,7 +58,7 @@ describe :forked_from_project do end def fork_project(from_project, user) - context = Projects::ForkContext.new(from_project, user) + context = Projects::ForkService.new(from_project, user) shell = double("gitlab_shell") shell.stub(fork_repository: true) context.stub(gitlab_shell: shell) diff --git a/spec/contexts/fork_context_spec.rb b/spec/services/fork_service_spec.rb similarity index 94% rename from spec/contexts/fork_context_spec.rb rename to spec/services/fork_service_spec.rb index 70f650bc83d..b6573095dbd 100644 --- a/spec/contexts/fork_context_spec.rb +++ b/spec/services/fork_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Projects::ForkContext do +describe Projects::ForkService do describe :fork_by_user do before do @from_namespace = create(:namespace) @@ -47,7 +47,7 @@ describe Projects::ForkContext do end def fork_project(from_project, user, fork_success = true) - context = Projects::ForkContext.new(from_project, user) + context = Projects::ForkService.new(from_project, user) shell = double("gitlab_shell") shell.stub(fork_repository: fork_success) context.stub(gitlab_shell: shell) diff --git a/spec/contexts/issues/bulk_update_context_spec.rb b/spec/services/issues/bulk_update_context_spec.rb similarity index 85% rename from spec/contexts/issues/bulk_update_context_spec.rb rename to spec/services/issues/bulk_update_context_spec.rb index 058e43ba090..548109a8450 100644 --- a/spec/contexts/issues/bulk_update_context_spec.rb +++ b/spec/services/issues/bulk_update_context_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Issues::BulkUpdateContext do +describe Issues::BulkUpdateService do before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } @@ -14,7 +14,7 @@ describe Issues::BulkUpdateContext do name: "GitLab", namespace: @user.namespace } - @project = Projects::CreateContext.new(@user, opts).execute + @project = Projects::CreateService.new(@user, opts).execute end describe :close_issue do @@ -32,7 +32,7 @@ describe Issues::BulkUpdateContext do end it { - result = Issues::BulkUpdateContext.new(@project, @user, @params).execute + result = Issues::BulkUpdateService.new(@project, @user, @params).execute result[:success].should be_true result[:count].should == @issues.count @@ -57,7 +57,7 @@ describe Issues::BulkUpdateContext do end it { - result = Issues::BulkUpdateContext.new(@project, @user, @params).execute + result = Issues::BulkUpdateService.new(@project, @user, @params).execute result[:success].should be_true result[:count].should == @issues.count @@ -80,7 +80,7 @@ describe Issues::BulkUpdateContext do end it { - result = Issues::BulkUpdateContext.new(@project, @user, @params).execute + result = Issues::BulkUpdateService.new(@project, @user, @params).execute result[:success].should be_true result[:count].should == 1 @@ -102,7 +102,7 @@ describe Issues::BulkUpdateContext do end it { - result = Issues::BulkUpdateContext.new(@project, @user, @params).execute + result = Issues::BulkUpdateService.new(@project, @user, @params).execute result[:success].should be_true result[:count].should == 1 diff --git a/spec/contexts/projects_create_context_spec.rb b/spec/services/projects_create_service_spec.rb similarity index 98% rename from spec/contexts/projects_create_context_spec.rb rename to spec/services/projects_create_service_spec.rb index d5b1cb83510..0a41832a211 100644 --- a/spec/contexts/projects_create_context_spec.rb +++ b/spec/services/projects_create_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Projects::CreateContext do +describe Projects::CreateService do before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } @@ -136,7 +136,7 @@ describe Projects::CreateContext do end def create_project(user, opts) - Projects::CreateContext.new(user, opts).execute + Projects::CreateService.new(user, opts).execute end end diff --git a/spec/contexts/projects_update_context_spec.rb b/spec/services/projects_update_service_spec.rb similarity index 97% rename from spec/contexts/projects_update_context_spec.rb rename to spec/services/projects_update_service_spec.rb index edcaf844e5d..1854c0d8233 100644 --- a/spec/contexts/projects_update_context_spec.rb +++ b/spec/services/projects_update_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Projects::UpdateContext do +describe Projects::UpdateService do before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } @@ -106,6 +106,6 @@ describe Projects::UpdateContext do end def update_project(project, user, opts) - Projects::UpdateContext.new(project, user, opts).execute + Projects::UpdateService.new(project, user, opts).execute end -end \ No newline at end of file +end diff --git a/spec/contexts/search_context_spec.rb b/spec/services/search_service_spec.rb similarity index 89% rename from spec/contexts/search_context_spec.rb rename to spec/services/search_service_spec.rb index 38a6b55383a..457cb3c0ca3 100644 --- a/spec/contexts/search_context_spec.rb +++ b/spec/services/search_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Search::GlobalContext' do +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) } @@ -19,7 +19,7 @@ describe 'Search::GlobalContext' do describe '#execute' do context 'unauthenticated' do it 'should return public projects only' do - context = Search::GlobalContext.new(nil, search: "searchable") + context = Search::GlobalService.new(nil, search: "searchable") results = context.execute results[:projects].should have(1).items results[:projects].should include(public_project) @@ -28,7 +28,7 @@ describe 'Search::GlobalContext' do context 'authenticated' do it 'should return public, internal and private projects' do - context = Search::GlobalContext.new(user, search: "searchable") + context = Search::GlobalService.new(user, search: "searchable") results = context.execute results[:projects].should have(3).items results[:projects].should include(public_project) @@ -37,7 +37,7 @@ describe 'Search::GlobalContext' do end it 'should return only public & internal projects' do - context = Search::GlobalContext.new(internal_user, search: "searchable") + context = Search::GlobalService.new(internal_user, search: "searchable") results = context.execute results[:projects].should have(2).items results[:projects].should include(internal_project) @@ -45,7 +45,7 @@ describe 'Search::GlobalContext' do end it 'namespace name should be searchable' do - context = Search::GlobalContext.new(user, search: "searchable namespace") + context = Search::GlobalService.new(user, search: "searchable namespace") results = context.execute results[:projects].should == [found_project] end