Commit 2bac79a9 authored by Ragnar-H's avatar Ragnar-H

Move feature flag specs down a test level

Controller specs are more focused and run faster.
parent 97c8f825
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Groups::UsageQuotasController do
let_it_be(:group) { create(:group, :private) }
let_it_be(:user) { create(:user) }
before do
sign_in(user)
group.add_owner(user)
end
describe 'Pushing the `additionalRepoStorageByNamespace` feature flag to the frontend' do
context 'when both flags are true' do
before do
stub_feature_flags(additional_repo_storage_by_namespace: true, namespace_storage_limit: true)
end
it 'is disabled' do
get :index, params: { group_id: group }
expect(Gon.features).to include('additionalRepoStorageByNamespace' => false)
end
end
context 'when `namespace_storage_limit` flag is false' do
before do
stub_feature_flags(additional_repo_storage_by_namespace: true, namespace_storage_limit: false)
end
it 'is enabled' do
get :index, params: { group_id: group }
expect(Gon.features).to include('additionalRepoStorageByNamespace' => true)
end
end
context 'when both flags are false' do
before do
stub_feature_flags(additional_repo_storage_by_namespace: false, namespace_storage_limit: false)
end
it 'is disabled' do
get :index, params: { group_id: group }
expect(Gon.features).to include('additionalRepoStorageByNamespace' => false)
end
end
end
end
......@@ -16,4 +16,42 @@ RSpec.describe Profiles::UsageQuotasController do
expect(subject).to render_template(:index)
end
end
describe 'Pushing the `additionalRepoStorageByNamespace` feature flag to the frontend' do
context 'when both flags are true' do
before do
stub_feature_flags(additional_repo_storage_by_namespace: true, namespace_storage_limit: true)
end
it 'is disabled' do
get :index
expect(Gon.features).to include('additionalRepoStorageByNamespace' => false)
end
end
context 'when `namespace_storage_limit` flag is false' do
before do
stub_feature_flags(additional_repo_storage_by_namespace: true, namespace_storage_limit: false)
end
it 'is enabled' do
get :index
expect(Gon.features).to include('additionalRepoStorageByNamespace' => true)
end
end
context 'when both flags are false' do
before do
stub_feature_flags(additional_repo_storage_by_namespace: false, namespace_storage_limit: false)
end
it 'is disabled' do
get :index
expect(Gon.features).to include('additionalRepoStorageByNamespace' => false)
end
end
end
end
......@@ -9,49 +9,12 @@ RSpec.describe 'Groups > Usage Quotas' do
let(:gitlab_dot_com) { true }
before do
stub_feature_flags(additional_repo_storage_by_namespace: true, namespace_storage_limit: false)
allow(Gitlab).to receive(:com?).and_return(gitlab_dot_com)
group.add_owner(user)
sign_in(user)
end
it 'pushes frontend feature flags' do
visit visit_pipeline_quota_page
expect(page).to have_pushed_frontend_feature_flags(
additionalRepoStorageByNamespace: true
)
end
context 'when `additional_repo_storage_by_namespace` is disabled for a group' do
before do
stub_feature_flags(additional_repo_storage_by_namespace: false, thing: group)
end
it 'pushes disabled feature flag to the frontend' do
visit visit_pipeline_quota_page
expect(page).to have_pushed_frontend_feature_flags(
additionalRepoStorageByNamespace: false
)
end
end
context 'when `additional_repo_storage_by_namespace` is overruled by `namespace_storage_limit`' do
before do
stub_feature_flags(namespace_storage_limit: true, thing: group)
end
it 'pushes disabled feature flag to the frontend' do
visit profile_usage_quotas_path
expect(page).to have_pushed_frontend_feature_flags(
additionalRepoStorageByNamespace: false
)
end
end
shared_examples 'linked in group settings dropdown' do
it 'is linked within the group settings dropdown' do
visit edit_group_path(group)
......
......@@ -12,46 +12,9 @@ RSpec.describe 'Profile > Usage Quota' do
let_it_be(:other_project) { create(:project, namespace: namespace, shared_runners_enabled: false) }
before do
stub_feature_flags(additional_repo_storage_by_namespace: true, namespace_storage_limit: false)
gitlab_sign_in(user)
end
it 'pushes frontend feature flags' do
visit profile_usage_quotas_path
expect(page).to have_pushed_frontend_feature_flags(
additionalRepoStorageByNamespace: true
)
end
context 'when `additional_repo_storage_by_namespace` is disabled for a namespace' do
before do
stub_feature_flags(additional_repo_storage_by_namespace: false, thing: namespace)
end
it 'pushes disabled feature flag to the frontend' do
visit profile_usage_quotas_path
expect(page).to have_pushed_frontend_feature_flags(
additionalRepoStorageByNamespace: false
)
end
end
context 'when `additional_repo_storage_by_namespace` is overruled by `namespace_storage_limit`' do
before do
stub_feature_flags(namespace_storage_limit: true, thing: namespace)
end
it 'pushes disabled feature flag to the frontend' do
visit profile_usage_quotas_path
expect(page).to have_pushed_frontend_feature_flags(
additionalRepoStorageByNamespace: false
)
end
end
it 'is linked within the profile page' do
visit profile_path
......
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