diff options
Diffstat (limited to 'spec/requests/api/api_helpers_spec.rb')
-rw-r--r-- | spec/requests/api/api_helpers_spec.rb | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/spec/requests/api/api_helpers_spec.rb b/spec/requests/api/api_helpers_spec.rb index 831889afb6c..c65510fadec 100644 --- a/spec/requests/api/api_helpers_spec.rb +++ b/spec/requests/api/api_helpers_spec.rb @@ -41,19 +41,19 @@ describe API::Helpers, api: true do describe ".current_user" do describe "when authenticating using a user's private token" do - it "should return nil for an invalid token" do + it "returns nil for an invalid token" do env[API::Helpers::PRIVATE_TOKEN_HEADER] = 'invalid token' allow_any_instance_of(self.class).to receive(:doorkeeper_guard){ false } expect(current_user).to be_nil end - it "should return nil for a user without access" do + it "returns nil for a user without access" do env[API::Helpers::PRIVATE_TOKEN_HEADER] = user.private_token allow_any_instance_of(Gitlab::UserAccess).to receive(:allowed?).and_return(false) expect(current_user).to be_nil end - it "should leave user as is when sudo not specified" do + it "leaves user as is when sudo not specified" do env[API::Helpers::PRIVATE_TOKEN_HEADER] = user.private_token expect(current_user).to eq(user) clear_env @@ -65,19 +65,19 @@ describe API::Helpers, api: true do describe "when authenticating using a user's personal access tokens" do let(:personal_access_token) { create(:personal_access_token, user: user) } - it "should return nil for an invalid token" do + it "returns nil for an invalid token" do env[API::Helpers::PRIVATE_TOKEN_HEADER] = 'invalid token' allow_any_instance_of(self.class).to receive(:doorkeeper_guard){ false } expect(current_user).to be_nil end - it "should return nil for a user without access" do + it "returns nil for a user without access" do env[API::Helpers::PRIVATE_TOKEN_HEADER] = personal_access_token.token allow_any_instance_of(Gitlab::UserAccess).to receive(:allowed?).and_return(false) expect(current_user).to be_nil end - it "should leave user as is when sudo not specified" do + it "leaves user as is when sudo not specified" do env[API::Helpers::PRIVATE_TOKEN_HEADER] = personal_access_token.token expect(current_user).to eq(user) clear_env @@ -100,7 +100,7 @@ describe API::Helpers, api: true do end end - it "should change current user to sudo when admin" do + it "changes current user to sudo when admin" do set_env(admin, user.id) expect(current_user).to eq(user) set_param(admin, user.id) @@ -111,7 +111,7 @@ describe API::Helpers, api: true do expect(current_user).to eq(user) end - it "should throw an error when the current user is not an admin and attempting to sudo" do + it "throws an error when the current user is not an admin and attempting to sudo" do set_env(user, admin.id) expect { current_user }.to raise_error(Exception) set_param(user, admin.id) @@ -122,7 +122,7 @@ describe API::Helpers, api: true do expect { current_user }.to raise_error(Exception) end - it "should throw an error when the user cannot be found for a given id" do + it "throws an error when the user cannot be found for a given id" do id = user.id + admin.id expect(user.id).not_to eq(id) expect(admin.id).not_to eq(id) @@ -133,7 +133,7 @@ describe API::Helpers, api: true do expect { current_user }.to raise_error(Exception) end - it "should throw an error when the user cannot be found for a given username" do + it "throws an error when the user cannot be found for a given username" do username = "#{user.username}#{admin.username}" expect(user.username).not_to eq(username) expect(admin.username).not_to eq(username) @@ -144,7 +144,7 @@ describe API::Helpers, api: true do expect { current_user }.to raise_error(Exception) end - it "should handle sudo's to oneself" do + it "handles sudo's to oneself" do set_env(admin, admin.id) expect(current_user).to eq(admin) set_param(admin, admin.id) @@ -155,7 +155,7 @@ describe API::Helpers, api: true do expect(current_user).to eq(admin) end - it "should handle multiple sudo's to oneself" do + it "handles multiple sudo's to oneself" do set_env(admin, user.id) expect(current_user).to eq(user) expect(current_user).to eq(user) @@ -171,7 +171,7 @@ describe API::Helpers, api: true do expect(current_user).to eq(user) end - it "should handle multiple sudo's to oneself using string ids" do + it "handles multiple sudo's to oneself using string ids" do set_env(admin, user.id.to_s) expect(current_user).to eq(user) expect(current_user).to eq(user) @@ -183,7 +183,7 @@ describe API::Helpers, api: true do end describe '.sudo_identifier' do - it "should return integers when input is an int" do + it "returns integers when input is an int" do set_env(admin, '123') expect(sudo_identifier).to eq(123) set_env(admin, '0001234567890') @@ -195,7 +195,7 @@ describe API::Helpers, api: true do expect(sudo_identifier).to eq(1234567890) end - it "should return string when input is an is not an int" do + it "returns string when input is an is not an int" do set_env(admin, '12.30') expect(sudo_identifier).to eq("12.30") set_env(admin, 'hello') |