diff options
Diffstat (limited to 'spec/requests/api/internal/base_spec.rb')
-rw-r--r-- | spec/requests/api/internal/base_spec.rb | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/spec/requests/api/internal/base_spec.rb b/spec/requests/api/internal/base_spec.rb index 95513776f39..be592ac6a5c 100644 --- a/spec/requests/api/internal/base_spec.rb +++ b/spec/requests/api/internal/base_spec.rb @@ -575,30 +575,35 @@ describe API::Internal::Base do project.add_developer(user) end - context "git pull" do - context "with no console message" do - it "has the correct payload" do + context 'git pull' do + context 'with a key that has expired' do + let(:key) { create(:key, user: user, expires_at: 2.days.ago) } + + it 'includes the `key expired` message in the response' do pull(key, project) expect(response).to have_gitlab_http_status(:ok) - expect(json_response['gl_console_messages']).to eq([]) + expect(json_response['gl_console_messages']).to eq(['INFO: Your SSH key has expired. Please generate a new key.']) end end - context "with a console message" do - let(:console_messages) { ['message for the console'] } + context 'with a key that will expire in the next 7 days' do + let(:key) { create(:key, user: user, expires_at: 2.days.from_now) } - it "has the correct payload" do - expect_next_instance_of(Gitlab::GitAccess) do |access| - expect(access).to receive(:check_for_console_messages) - .with('git-upload-pack') - .and_return(console_messages) - end + it 'includes the `key expiring soon` message in the response' do + pull(key, project) + expect(response).to have_gitlab_http_status(:ok) + expect(json_response['gl_console_messages']).to eq(['INFO: Your SSH key is expiring soon. Please generate a new key.']) + end + end + + context 'with a key that has no expiry' do + it 'does not include any message in the response' do pull(key, project) expect(response).to have_gitlab_http_status(:ok) - expect(json_response['gl_console_messages']).to eq(console_messages) + expect(json_response['gl_console_messages']).to eq([]) end end end |