From 648826721f13ee4309a11638e538d96006648b39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20=C4=8Cupi=C4=87?= Date: Fri, 2 Feb 2018 22:51:03 +0100 Subject: Rename Callout to UserCallout --- spec/controllers/user_callouts_controller_spec.rb | 35 +++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 spec/controllers/user_callouts_controller_spec.rb (limited to 'spec/controllers/user_callouts_controller_spec.rb') diff --git a/spec/controllers/user_callouts_controller_spec.rb b/spec/controllers/user_callouts_controller_spec.rb new file mode 100644 index 00000000000..ac295aa72bb --- /dev/null +++ b/spec/controllers/user_callouts_controller_spec.rb @@ -0,0 +1,35 @@ +require 'spec_helper' + +describe UserCalloutsController do + let(:user) { create(:user) } + + before do + sign_in(user) + end + + describe "POST #create" do + subject { post :create, 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 { UserCallout.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(:user_callout, feature_name: 'feature_name', user: user) } + + it 'should return success' do + subject + + expect(response).to have_gitlab_http_status(:ok) + end + end + end +end -- cgit v1.2.1 From 20714ee90232b5577fc99f2a773ddccf71482c08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20=C4=8Cupi=C4=87?= Date: Sat, 3 Feb 2018 00:16:24 +0100 Subject: Change UserCallout feautre_name to enum --- spec/controllers/user_callouts_controller_spec.rb | 36 ++++++++++++++++------- 1 file changed, 25 insertions(+), 11 deletions(-) (limited to 'spec/controllers/user_callouts_controller_spec.rb') diff --git a/spec/controllers/user_callouts_controller_spec.rb b/spec/controllers/user_callouts_controller_spec.rb index ac295aa72bb..48e2ff75cac 100644 --- a/spec/controllers/user_callouts_controller_spec.rb +++ b/spec/controllers/user_callouts_controller_spec.rb @@ -8,27 +8,41 @@ describe UserCalloutsController do end describe "POST #create" do - subject { post :create, feature_name: 'feature_name', format: :json } + subject { post :create, 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 { UserCallout.count }.by(1) + context 'with valid feature name' do + let(:feature_name) { UserCallout.feature_names.keys.first } + + context 'when callout entry does not exist' do + it 'should create a callout entry with dismissed state' do + expect { subject }.to change { UserCallout.count }.by(1) + end + + it 'should return success' do + subject + + expect(response).to have_gitlab_http_status(:ok) + end end - it 'should return success' do - subject + context 'when callout entry already exists' do + let!(:callout) { create(:user_callout, feature_name: UserCallout.feature_names.keys.first, user: user) } + + it 'should return success' do + subject - expect(response).to have_gitlab_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) + end end end - context 'when callout entry already exists' do - let!(:callout) { create(:user_callout, feature_name: 'feature_name', user: user) } + context 'with invalid feature name' do + let(:feature_name) { 'bogus_feature_name' } - it 'should return success' do + it 'should return bad request' do subject - expect(response).to have_gitlab_http_status(:ok) + expect(response).to have_gitlab_http_status(:bad_request) end end end -- cgit v1.2.1