OSDN Git Service

Replace context with service in specs
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Thu, 16 Jan 2014 18:29:18 +0000 (20:29 +0200)
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Thu, 16 Jan 2014 18:29:18 +0000 (20:29 +0200)
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
spec/models/forked_project_link_spec.rb
spec/services/fork_service_spec.rb [moved from spec/contexts/fork_context_spec.rb with 94% similarity]
spec/services/issues/bulk_update_context_spec.rb [moved from spec/contexts/issues/bulk_update_context_spec.rb with 85% similarity]
spec/services/projects_create_service_spec.rb [moved from spec/contexts/projects_create_context_spec.rb with 98% similarity]
spec/services/projects_update_service_spec.rb [moved from spec/contexts/projects_update_context_spec.rb with 97% similarity]
spec/services/search_service_spec.rb [moved from spec/contexts/search_context_spec.rb with 89% similarity]

index 472ddf1..e719e3b 100644 (file)
@@ -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)
similarity index 94%
rename from spec/contexts/fork_context_spec.rb
rename to spec/services/fork_service_spec.rb
index 70f650b..b657309 100644 (file)
@@ -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)
@@ -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
 
@@ -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
 
@@ -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
similarity index 89%
rename from spec/contexts/search_context_spec.rb
rename to spec/services/search_service_spec.rb
index 38a6b55..457cb3c 100644 (file)
@@ -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