summaryrefslogtreecommitdiff
path: root/spec/models/key_spec.rb
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-11-17 20:00:03 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-11-17 20:00:03 +0100
commit8a7860fd7fe91a9d2642dab9e66be5b22012901d (patch)
tree8215c73a6f4d648b98bf5a7d47be1fd70afd1c29 /spec/models/key_spec.rb
parent4dbed5a249265b3690888b3fcfc91da44412f7f1 (diff)
parent726a414169e6c3219ff4fd410da3efd53fc7f912 (diff)
downloadgitlab-ce-8a7860fd7fe91a9d2642dab9e66be5b22012901d.tar.gz
Merge branch 'master' into 22539-display-folders
* master: (154 commits) Fix typos Fix wrong changelog item Add missing item for 8.13.6 Change last_used_at to use touch Add chat_name partial Mention Git strategy none Fix code review adds fix for security issue when annonymous user does not ... Remove ToC since it's now supported in the docs portal itself Add 8.14 to versions with further additions to review apps Add Limitations sections to environments and review apps docs Add link to environments docs Fix URL to review apps docs Add a prerequisites section, add some links Link to NGINX example project for the time being Get rid most of the irrelevant sections Add note about current limitation in $CI_BUILD_REF_NAME Add an intro and an Overview section for Review Apps WIP review apps Add Review apps link to CI README ... Conflicts: spec/features/environments_spec.rb
Diffstat (limited to 'spec/models/key_spec.rb')
-rw-r--r--spec/models/key_spec.rb22
1 files changed, 16 insertions, 6 deletions
diff --git a/spec/models/key_spec.rb b/spec/models/key_spec.rb
index 7fc6ed1dd54..1a26cee9f3d 100644
--- a/spec/models/key_spec.rb
+++ b/spec/models/key_spec.rb
@@ -71,15 +71,25 @@ describe Key, models: true do
context 'callbacks' do
it 'adds new key to authorized_file' do
- @key = build(:personal_key, id: 7)
- expect(GitlabShellWorker).to receive(:perform_async).with(:add_key, @key.shell_id, @key.key)
- @key.save
+ key = build(:personal_key, id: 7)
+ expect(GitlabShellWorker).to receive(:perform_async).with(:add_key, key.shell_id, key.key)
+ key.save!
end
it 'removes key from authorized_file' do
- @key = create(:personal_key)
- expect(GitlabShellWorker).to receive(:perform_async).with(:remove_key, @key.shell_id, @key.key)
- @key.destroy
+ key = create(:personal_key)
+ expect(GitlabShellWorker).to receive(:perform_async).with(:remove_key, key.shell_id, key.key)
+ key.destroy
+ end
+ end
+
+ describe '#key=' do
+ let(:valid_key) do
+ "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0= dummy@gitlab.com"
+ end
+
+ it 'strips white spaces' do
+ expect(described_class.new(key: " #{valid_key} ").key).to eq(valid_key)
end
end
end