diff options
author | Robert Speicher <rspeicher@gmail.com> | 2016-02-18 21:50:49 -0500 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2016-02-18 21:50:49 -0500 |
commit | dfca5bfa47fa3adcdd8f80ebe92905d1e533b842 (patch) | |
tree | 61542e0fddc6bcb702404e962b6e615bc6f84f87 /spec/controllers/profiles | |
parent | ea4d2741a2b574407b0bd387ccd6a8202c014fc5 (diff) | |
download | gitlab-ce-dfca5bfa47fa3adcdd8f80ebe92905d1e533b842.tar.gz |
Move a few controller specs to their correct locationsrs-move-controller-specs
Diffstat (limited to 'spec/controllers/profiles')
-rw-r--r-- | spec/controllers/profiles/keys_controller_spec.rb | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/spec/controllers/profiles/keys_controller_spec.rb b/spec/controllers/profiles/keys_controller_spec.rb new file mode 100644 index 00000000000..b6573f105dc --- /dev/null +++ b/spec/controllers/profiles/keys_controller_spec.rb @@ -0,0 +1,70 @@ +require 'spec_helper' + +describe Profiles::KeysController do + let(:user) { create(:user) } + + describe "#get_keys" do + describe "non existant user" do + it "should generally not work" do + get :get_keys, username: 'not-existent' + + expect(response).not_to be_success + end + end + + describe "user with no keys" do + it "should generally work" do + get :get_keys, username: user.username + + expect(response).to be_success + end + + it "should render all keys separated with a new line" do + get :get_keys, username: user.username + + expect(response.body).to eq("") + end + + it "should respond with text/plain content type" do + get :get_keys, username: user.username + expect(response.content_type).to eq("text/plain") + end + end + + describe "user with keys" do + before do + user.keys << create(:key) + user.keys << create(:another_key) + end + + it "should generally work" do + get :get_keys, username: user.username + + expect(response).to be_success + end + + it "should render all keys separated with a new line" do + get :get_keys, username: user.username + + expect(response.body).not_to eq("") + expect(response.body).to eq(user.all_ssh_keys.join("\n")) + + # Unique part of key 1 + expect(response.body).to match(/PWx6WM4lhHNedGfBpPJNPpZ/) + # Key 2 + expect(response.body).to match(/AQDmTillFzNTrrGgwaCKaSj/) + end + + it "should not render the comment of the key" do + get :get_keys, username: user.username + + expect(response.body).not_to match(/dummy@gitlab.com/) + end + + it "should respond with text/plain content type" do + get :get_keys, username: user.username + expect(response.content_type).to eq("text/plain") + end + end + end +end |