Replace context with service in specs

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
Dmitriy Zaporozhets 2014-01-16 20:29:18 +02:00
parent 1d2bdb4d58
commit 4a1654ed6a
No known key found for this signature in database
GPG key ID: 627C5F589F467F17
6 changed files with 19 additions and 19 deletions

View 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)

View 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)

View file

@ -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

View file

@ -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

View file

@ -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
end

View 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