debian-mirror-gitlab/spec/controllers/user_callouts_controller_spec.rb

52 lines
1.2 KiB
Ruby
Raw Normal View History

2019-07-31 22:56:46 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
require 'spec_helper'
describe UserCalloutsController do
let(:user) { create(:user) }
before do
sign_in(user)
end
describe "POST #create" do
2019-02-15 15:39:39 +05:30
subject { post :create, params: { feature_name: feature_name }, format: :json }
2018-03-17 18:26:18 +05:30
context 'with valid feature name' do
let(:feature_name) { UserCallout.feature_names.keys.first }
context 'when callout entry does not exist' do
2019-07-07 11:18:12 +05:30
it 'creates a callout entry with dismissed state' do
2018-03-17 18:26:18 +05:30
expect { subject }.to change { UserCallout.count }.by(1)
end
2019-07-07 11:18:12 +05:30
it 'returns success' do
2018-03-17 18:26:18 +05:30
subject
expect(response).to have_gitlab_http_status(:ok)
end
end
context 'when callout entry already exists' do
let!(:callout) { create(:user_callout, feature_name: UserCallout.feature_names.keys.first, user: user) }
2019-07-07 11:18:12 +05:30
it 'returns success' do
2018-03-17 18:26:18 +05:30
subject
expect(response).to have_gitlab_http_status(:ok)
end
end
end
context 'with invalid feature name' do
let(:feature_name) { 'bogus_feature_name' }
2019-07-07 11:18:12 +05:30
it 'returns bad request' do
2018-03-17 18:26:18 +05:30
subject
expect(response).to have_gitlab_http_status(:bad_request)
end
end
end
end