diff options
author | Rémy Coutable <remy@rymai.me> | 2016-12-13 17:53:00 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-12-13 17:53:00 +0300 |
commit | d95b709a66a5597dced25a2b9df9a1e24fc6d49a (patch) | |
tree | 996f7de7904424329c246d256ab588e1e844e09b /spec | |
parent | 2f45d3bcf0f28d4cd4124b4c9722edc1d3085201 (diff) |
Be smarter when finding a sudoed user in API::Helpers
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/user_spec.rb | 11 | ||||
-rw-r--r-- | spec/requests/api/helpers_spec.rb | 4 |
2 files changed, 2 insertions, 13 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index bad6ed9e146..8b20ee81614 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -727,17 +727,6 @@ describe User, models: true do end end - describe 'by_username_or_id' do - let(:user1) { create(:user, username: 'foo') } - - it "gets the correct user" do - expect(User.by_username_or_id(user1.id)).to eq(user1) - expect(User.by_username_or_id('foo')).to eq(user1) - expect(User.by_username_or_id(-1)).to be_nil - expect(User.by_username_or_id('bar')).to be_nil - end - end - describe '.find_by_ssh_key_id' do context 'using an existing SSH key ID' do let(:user) { create(:user) } diff --git a/spec/requests/api/helpers_spec.rb b/spec/requests/api/helpers_spec.rb index 573154f69b4..4035fd97af5 100644 --- a/spec/requests/api/helpers_spec.rb +++ b/spec/requests/api/helpers_spec.rb @@ -16,14 +16,14 @@ describe API::Helpers, api: true do clear_env clear_param env[API::Helpers::PRIVATE_TOKEN_HEADER] = user_or_token.respond_to?(:private_token) ? user_or_token.private_token : user_or_token - env[API::Helpers::SUDO_HEADER] = identifier + env[API::Helpers::SUDO_HEADER] = identifier.to_s end def set_param(user_or_token, identifier) clear_env clear_param params[API::Helpers::PRIVATE_TOKEN_PARAM] = user_or_token.respond_to?(:private_token) ? user_or_token.private_token : user_or_token - params[API::Helpers::SUDO_PARAM] = identifier + params[API::Helpers::SUDO_PARAM] = identifier.to_s end def clear_env |