diff options
author | Matija Čupić <matteeyah@gmail.com> | 2018-01-26 22:49:20 +0100 |
---|---|---|
committer | Matija Čupić <matteeyah@gmail.com> | 2018-01-26 23:24:27 +0100 |
commit | bca10385539b44b39c28586d2d795e66a5e5e907 (patch) | |
tree | e896fe976d2b6d8a2c5518dd478cb8696d92d2b0 /spec/controllers | |
parent | c4667f87037150a408da5c133e573714807e17b3 (diff) | |
download | gitlab-ce-bca10385539b44b39c28586d2d795e66a5e5e907.tar.gz |
Add CalloutsController specs
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/callouts_controller_spec.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/controllers/callouts_controller_spec.rb b/spec/controllers/callouts_controller_spec.rb new file mode 100644 index 00000000000..bf2aae190f2 --- /dev/null +++ b/spec/controllers/callouts_controller_spec.rb @@ -0,0 +1,39 @@ +require 'spec_helper' + +describe CalloutsController do + let(:user) { create(:user) } + + before do + sign_in(user) + end + + describe "POST #dismiss" do + subject { post :dismiss, feature_name: 'feature_name', format: :json } + + context 'when callout entry does not exist' do + it 'should create a callout entry with dismissed state' do + expect { subject }.to change { Callout.count }.by(1) + end + + it 'should return success' do + subject + + expect(response).to have_gitlab_http_status(:ok) + end + end + + context 'when callout entry already exists' do + let!(:callout) { create(:callout, feature_name: 'feature_name', user: user) } + + it 'should update it with a dismissed state' do + expect { subject }.to change { callout.reload.dismissed_state }.from(false).to(true) + end + + it 'should return success' do + subject + + expect(response).to have_gitlab_http_status(:ok) + end + end + end +end |