summaryrefslogtreecommitdiff
path: root/spec/lib/api/helpers_spec.rb
diff options
context:
space:
mode:
authorToon Claes <toon@gitlab.com>2019-02-28 19:57:34 +0100
committerToon Claes <toon@gitlab.com>2019-02-28 19:57:34 +0100
commit62d7990b9bb30cf33ed87017c5c633d1cccc75c2 (patch)
treec3e1b69c58a412ba1c6f50a0337a23d9f9d6e1a4 /spec/lib/api/helpers_spec.rb
parentf6453eca992a9c142268e78ac782cef98110d183 (diff)
downloadgitlab-ce-tc-standard-gem.tar.gz
Ran standardrb --fix on the whole codebasetc-standard-gem
Inspired by https://twitter.com/searls/status/1101137953743613952 I decided to try https://github.com/testdouble/standard on our codebase. It's opinionated, but at least it's a _standard_.
Diffstat (limited to 'spec/lib/api/helpers_spec.rb')
-rw-r--r--spec/lib/api/helpers_spec.rb102
1 files changed, 51 insertions, 51 deletions
diff --git a/spec/lib/api/helpers_spec.rb b/spec/lib/api/helpers_spec.rb
index 08165f147bb..e677b3910ee 100644
--- a/spec/lib/api/helpers_spec.rb
+++ b/spec/lib/api/helpers_spec.rb
@@ -1,42 +1,42 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Helpers do
subject { Class.new.include(described_class).new }
- describe '#find_project' do
+ describe "#find_project" do
let(:project) { create(:project) }
- shared_examples 'project finder' do
- context 'when project exists' do
- it 'returns requested project' do
+ shared_examples "project finder" do
+ context "when project exists" do
+ it "returns requested project" do
expect(subject.find_project(existing_id)).to eq(project)
end
- it 'returns nil' do
+ it "returns nil" do
expect(subject.find_project(non_existing_id)).to be_nil
end
end
end
- context 'when ID is used as an argument' do
+ context "when ID is used as an argument" do
let(:existing_id) { project.id }
let(:non_existing_id) { (Project.maximum(:id) || 0) + 1 }
- it_behaves_like 'project finder'
+ it_behaves_like "project finder"
end
- context 'when PATH is used as an argument' do
+ context "when PATH is used as an argument" do
let(:existing_id) { project.full_path }
- let(:non_existing_id) { 'something/else' }
+ let(:non_existing_id) { "something/else" }
- it_behaves_like 'project finder'
+ it_behaves_like "project finder"
- context 'with an invalid PATH' do
- let(:non_existing_id) { 'undefined' } # path without slash
+ context "with an invalid PATH" do
+ let(:non_existing_id) { "undefined" } # path without slash
- it_behaves_like 'project finder'
+ it_behaves_like "project finder"
- it 'does not hit the database' do
+ it "does not hit the database" do
expect(Project).not_to receive(:find_by_full_path)
subject.find_project(non_existing_id)
@@ -45,64 +45,64 @@ describe API::Helpers do
end
end
- describe '#find_namespace' do
+ describe "#find_namespace" do
let(:namespace) { create(:namespace) }
- shared_examples 'namespace finder' do
- context 'when namespace exists' do
- it 'returns requested namespace' do
+ shared_examples "namespace finder" do
+ context "when namespace exists" do
+ it "returns requested namespace" do
expect(subject.find_namespace(existing_id)).to eq(namespace)
end
end
context "when namespace doesn't exists" do
- it 'returns nil' do
+ it "returns nil" do
expect(subject.find_namespace(non_existing_id)).to be_nil
end
end
end
- context 'when ID is used as an argument' do
+ context "when ID is used as an argument" do
let(:existing_id) { namespace.id }
let(:non_existing_id) { 9999 }
- it_behaves_like 'namespace finder'
+ it_behaves_like "namespace finder"
end
- context 'when PATH is used as an argument' do
+ context "when PATH is used as an argument" do
let(:existing_id) { namespace.path }
- let(:non_existing_id) { 'non-existing-path' }
+ let(:non_existing_id) { "non-existing-path" }
- it_behaves_like 'namespace finder'
+ it_behaves_like "namespace finder"
end
end
- shared_examples 'user namespace finder' do
+ shared_examples "user namespace finder" do
let(:user1) { create(:user) }
before do
allow(subject).to receive(:current_user).and_return(user1)
allow(subject).to receive(:header).and_return(nil)
- allow(subject).to receive(:not_found!).and_raise('404 Namespace not found')
+ allow(subject).to receive(:not_found!).and_raise("404 Namespace not found")
end
- context 'when namespace is group' do
+ context "when namespace is group" do
let(:namespace) { create(:group) }
- context 'when user has access to group' do
+ context "when user has access to group" do
before do
namespace.add_guest(user1)
namespace.save!
end
- it 'returns requested namespace' do
+ it "returns requested namespace" do
expect(namespace_finder).to eq(namespace)
end
end
context "when user doesn't have access to group" do
- it 'raises not found error' do
- expect { namespace_finder }.to raise_error(RuntimeError, '404 Namespace not found')
+ it "raises not found error" do
+ expect { namespace_finder }.to raise_error(RuntimeError, "404 Namespace not found")
end
end
end
@@ -110,48 +110,48 @@ describe API::Helpers do
context "when namespace is user's personal namespace" do
let(:namespace) { create(:namespace) }
- context 'when user owns the namespace' do
+ context "when user owns the namespace" do
before do
namespace.owner = user1
namespace.save!
end
- it 'returns requested namespace' do
+ it "returns requested namespace" do
expect(namespace_finder).to eq(namespace)
end
end
context "when user doesn't own the namespace" do
- it 'raises not found error' do
- expect { namespace_finder }.to raise_error(RuntimeError, '404 Namespace not found')
+ it "raises not found error" do
+ expect { namespace_finder }.to raise_error(RuntimeError, "404 Namespace not found")
end
end
end
end
- describe '#find_namespace!' do
+ describe "#find_namespace!" do
let(:namespace_finder) do
subject.find_namespace!(namespace.id)
end
- it_behaves_like 'user namespace finder'
+ it_behaves_like "user namespace finder"
end
- describe '#user_namespace' do
+ describe "#user_namespace" do
let(:namespace_finder) do
subject.user_namespace
end
before do
- allow(subject).to receive(:params).and_return({ id: namespace.id })
+ allow(subject).to receive(:params).and_return({id: namespace.id})
end
- it_behaves_like 'user namespace finder'
+ it_behaves_like "user namespace finder"
end
- describe '#send_git_blob' do
+ describe "#send_git_blob" do
let(:repository) { double }
- let(:blob) { double(name: 'foobar') }
+ let(:blob) { double(name: "foobar") }
let(:send_git_blob) do
subject.send(:send_git_blob, repository, blob)
@@ -164,22 +164,22 @@ describe API::Helpers do
allow(Gitlab::Workhorse).to receive(:send_git_blob)
end
- it 'sets Gitlab::Workhorse::DETECT_HEADER header' do
+ it "sets Gitlab::Workhorse::DETECT_HEADER header" do
expect(send_git_blob[Gitlab::Workhorse::DETECT_HEADER]).to eq "true"
end
- context 'content disposition' do
- context 'when blob name is null' do
+ context "content disposition" do
+ context "when blob name is null" do
let(:blob) { double(name: nil) }
- it 'returns only the disposition' do
- expect(send_git_blob['Content-Disposition']).to eq 'inline'
+ it "returns only the disposition" do
+ expect(send_git_blob["Content-Disposition"]).to eq "inline"
end
end
- context 'when blob name is not null' do
- it 'returns disposition with the blob name' do
- expect(send_git_blob['Content-Disposition']).to eq %q(inline; filename="foobar"; filename*=UTF-8''foobar)
+ context "when blob name is not null" do
+ it "returns disposition with the blob name" do
+ expect(send_git_blob["Content-Disposition"]).to eq %q(inline; filename="foobar"; filename*=UTF-8''foobar)
end
end
end