Commit 4a1654ed authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Replace context with service in specs

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 1d2bdb4d
......@@ -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)
......
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)
......
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
......
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
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
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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment