Commit 2084951f authored by Ash McKenzie's avatar Ash McKenzie

Merge branch 'ck3g-refactor-specs-for-feature_flags_controller' into 'master'

Refactor specs for FeatureFlagsController

See merge request gitlab-org/gitlab!24446
parents 2e33d3e6 fcc5da4f
......@@ -26,36 +26,24 @@ describe Projects::FeatureFlagsController do
subject { get(:index, params: view_params) }
context 'when there is no feature flags' do
before do
subject
end
it 'renders page' do
expect(response).to be_ok
it 'responds with success' do
is_expected.to have_gitlab_http_status(:ok)
end
end
context 'for a list of feature flags' do
let!(:feature_flags) { create_list(:operations_feature_flag, 50, project: project) }
before do
subject
end
it 'renders page' do
expect(response).to have_gitlab_http_status(:ok)
it 'responds with success' do
is_expected.to have_gitlab_http_status(:ok)
end
end
context 'when feature is not available' do
let(:feature_enabled) { false }
before do
subject
end
it 'shows not found' do
expect(subject).to have_gitlab_http_status(:not_found)
it 'responds with not found' do
is_expected.to have_gitlab_http_status(:not_found)
end
end
end
......@@ -102,9 +90,7 @@ describe Projects::FeatureFlagsController do
end
it 'matches json schema' do
subject
expect(response).to match_response_schema('feature_flags', dir: 'ee')
is_expected.to match_response_schema('feature_flags', dir: 'ee')
end
it 'returns false for active when the feature flag is inactive even if it has an active scope' do
......@@ -228,9 +214,7 @@ describe Projects::FeatureFlagsController do
subject { get(:new, params: view_params) }
it 'renders the form' do
subject
expect(response).to be_ok
is_expected.to have_gitlab_http_status(:ok)
end
end
......@@ -257,9 +241,7 @@ describe Projects::FeatureFlagsController do
end
it 'matches json schema' do
subject
expect(response).to match_response_schema('feature_flag', dir: 'ee')
is_expected.to match_response_schema('feature_flag', dir: 'ee')
end
context 'when feature flag is not found' do
......@@ -274,9 +256,7 @@ describe Projects::FeatureFlagsController do
end
it 'returns 404' do
subject
expect(response).to have_gitlab_http_status(:not_found)
is_expected.to have_gitlab_http_status(:not_found)
end
end
......@@ -284,9 +264,7 @@ describe Projects::FeatureFlagsController do
let(:user) { reporter }
it 'returns 404' do
subject
expect(response).to have_gitlab_http_status(:not_found)
is_expected.to have_gitlab_http_status(:not_found)
end
end
......@@ -346,9 +324,7 @@ describe Projects::FeatureFlagsController do
end
it 'returns 200' do
subject
expect(response).to have_gitlab_http_status(:ok)
is_expected.to have_gitlab_http_status(:ok)
end
it 'creates a new feature flag' do
......@@ -367,9 +343,7 @@ describe Projects::FeatureFlagsController do
end
it 'matches json schema' do
subject
expect(response).to match_response_schema('feature_flag', dir: 'ee')
is_expected.to match_response_schema('feature_flag', dir: 'ee')
end
context 'when the same named feature flag has already existed' do
......@@ -378,9 +352,7 @@ describe Projects::FeatureFlagsController do
end
it 'returns 400' do
subject
expect(response).to have_gitlab_http_status(:bad_request)
is_expected.to have_gitlab_http_status(:bad_request)
end
it 'returns an error message' do
......@@ -415,9 +387,7 @@ describe Projects::FeatureFlagsController do
let(:user) { reporter }
it 'returns 404' do
subject
expect(response).to have_gitlab_http_status(:not_found)
is_expected.to have_gitlab_http_status(:not_found)
end
end
......@@ -549,9 +519,7 @@ describe Projects::FeatureFlagsController do
end
it 'returns 200' do
subject
expect(response).to have_gitlab_http_status(:ok)
is_expected.to have_gitlab_http_status(:ok)
end
it 'deletes one feature flag' do
......@@ -563,18 +531,14 @@ describe Projects::FeatureFlagsController do
end
it 'matches json schema' do
subject
expect(response).to match_response_schema('feature_flag', dir: 'ee')
is_expected.to match_response_schema('feature_flag', dir: 'ee')
end
context 'when user is reporter' do
let(:user) { reporter }
it 'returns 404' do
subject
expect(response).to have_gitlab_http_status(:not_found)
is_expected.to have_gitlab_http_status(:not_found)
end
end
......@@ -609,9 +573,7 @@ describe Projects::FeatureFlagsController do
end
it 'returns 200' do
subject
expect(response).to have_gitlab_http_status(:ok)
is_expected.to have_gitlab_http_status(:ok)
end
it 'updates the name of the feature flag name' do
......@@ -621,9 +583,7 @@ describe Projects::FeatureFlagsController do
end
it 'matches json schema' do
subject
expect(response).to match_response_schema('feature_flag', dir: 'ee')
is_expected.to match_response_schema('feature_flag', dir: 'ee')
end
context 'when updates active' do
......@@ -672,9 +632,7 @@ describe Projects::FeatureFlagsController do
let(:user) { reporter }
it 'returns 404' do
subject
expect(response).to have_gitlab_http_status(:not_found)
is_expected.to have_gitlab_http_status(:not_found)
end
end
......@@ -711,9 +669,7 @@ describe Projects::FeatureFlagsController do
end
it 'returns 400' do
subject
expect(response).to have_gitlab_http_status(:bad_request)
is_expected.to have_gitlab_http_status(:bad_request)
end
end
......@@ -761,9 +717,7 @@ describe Projects::FeatureFlagsController do
end
it 'returns 400' do
subject
expect(response).to have_gitlab_http_status(:bad_request)
is_expected.to have_gitlab_http_status(:bad_request)
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment