summaryrefslogtreecommitdiff
path: root/spec/gitlab_access_spec.rb
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2018-08-08 17:38:38 +0000
committerRobert Speicher <robert@gitlab.com>2018-08-08 17:38:38 +0000
commit3aaf4751e09262c53544a1987f59b1308af9b6c1 (patch)
tree019332604ac4853db5d80bca95f229c95d1fc298 /spec/gitlab_access_spec.rb
parentc6577e0d75f51b017f2f332838b97c3ca5b497c0 (diff)
parent014691e057537a803e22223ea072065cc91938a7 (diff)
downloadgitlab-shell-3aaf4751e09262c53544a1987f59b1308af9b6c1.tar.gz
Merge branch 'ash.mckenzie/srp-refactor' into 'master'
Refactor that focuses on SRP improvements See merge request gitlab-org/gitlab-shell!214
Diffstat (limited to 'spec/gitlab_access_spec.rb')
-rw-r--r--spec/gitlab_access_spec.rb43
1 files changed, 15 insertions, 28 deletions
diff --git a/spec/gitlab_access_spec.rb b/spec/gitlab_access_spec.rb
index f9717a7..73ebf2e 100644
--- a/spec/gitlab_access_spec.rb
+++ b/spec/gitlab_access_spec.rb
@@ -7,31 +7,27 @@ describe GitlabAccess do
let(:repo_path) { File.join(repository_path, repo_name) + ".git" }
let(:api) do
double(GitlabNet).tap do |api|
- api.stub(check_access: GitAccessStatus.new(true,
- 'ok',
- gl_repository: 'project-1',
- gl_id: 'user-123',
- gl_username: 'testuser',
- repository_path: '/home/git/repositories',
- gitaly: nil,
- git_protocol: 'version=2'))
+ allow(api).to receive(:check_access).and_return(
+ Action::Gitaly.new(
+ 'key-1',
+ 'project-1',
+ 'testuser',
+ 'version=2',
+ '/home/git/repositories',
+ nil
+ )
+ )
end
end
subject do
GitlabAccess.new(nil, repo_path, 'key-123', 'wow', 'ssh').tap do |access|
- access.stub(exec_cmd: :exec_called)
- access.stub(api: api)
+ allow(access).to receive(:exec_cmd).and_return(:exec_called)
+ allow(access).to receive(:api).and_return(api)
end
end
before do
- GitlabConfig.any_instance.stub(repos_path: repository_path)
- end
-
- describe :initialize do
- it { subject.repo_path.should == repo_path }
- it { subject.changes.should == ['wow'] }
- it { subject.protocol.should == 'ssh' }
+ allow_any_instance_of(GitlabConfig).to receive(:repos_path).and_return(repository_path)
end
describe "#exec" do
@@ -43,16 +39,7 @@ describe GitlabAccess do
context "access is denied" do
before do
- api.stub(check_access: GitAccessStatus.new(
- false,
- 'denied',
- gl_repository: nil,
- gl_id: nil,
- gl_username: nil,
- repository_path: nil,
- gitaly: nil,
- git_protocol: nil
- ))
+ allow(api).to receive(:check_access).and_raise(AccessDeniedError)
end
it "returns false" do
@@ -62,7 +49,7 @@ describe GitlabAccess do
context "API connection fails" do
before do
- api.stub(:check_access).and_raise(GitlabNet::ApiUnreachableError)
+ allow(api).to receive(:check_access).and_raise(GitlabNet::ApiUnreachableError)
end
it "returns false" do