Only tech admins can manage page feature flags (#14618)
This commit is contained in:
parent
94841d5934
commit
e59fccabb3
2 changed files with 34 additions and 17 deletions
|
|
@ -74,23 +74,25 @@
|
|||
<%= render partial: "landing_page_modal", locals: { page: @landing_page } %>
|
||||
<% end %>
|
||||
|
||||
<div class="form-group">
|
||||
<p>
|
||||
<b><%= link_to "Feature Flag", "/admin/feature_flags" %></b>
|
||||
<span class="badge badge-<%= FeatureFlag.exist?(@page.feature_flag_name) ? "success" : "warning" %>">
|
||||
<%= FeatureFlag.exist?(@page.feature_flag_name) ? "Present" : "Not Present" %>
|
||||
</span>
|
||||
<br>
|
||||
<% if FeatureFlag.exist?(@page.feature_flag_name) %>
|
||||
Access to this page is being guarded by the feature flag <code><%= @page.feature_flag_name %></code>.
|
||||
<%= link_to "Modify flag here", "/admin/feature_flags/features/#{@page.feature_flag_name}" %>
|
||||
<% else %>
|
||||
Everyone has access. Optionally guard access to this page by creating feature <code><%= @page.feature_flag_name %></code>
|
||||
<%= link_to "here", "/admin/feature_flags/features" %>
|
||||
<% end %>
|
||||
<br>
|
||||
</p>
|
||||
</div>
|
||||
<% if current_user.has_role?(:tech_admin) %>
|
||||
<div class="form-group">
|
||||
<p>
|
||||
<b><%= link_to "Feature Flag", "/admin/feature_flags" %></b>
|
||||
<span class="badge badge-<%= FeatureFlag.exist?(@page.feature_flag_name) ? "success" : "warning" %>">
|
||||
<%= FeatureFlag.exist?(@page.feature_flag_name) ? "Present" : "Not Present" %>
|
||||
</span>
|
||||
<br>
|
||||
<% if FeatureFlag.exist?(@page.feature_flag_name) %>
|
||||
Access to this page is being guarded by the feature flag <code><%= @page.feature_flag_name %></code>.
|
||||
<%= link_to "Modify flag here", "/admin/feature_flags/features/#{@page.feature_flag_name}" %>
|
||||
<% else %>
|
||||
Everyone has access. Optionally guard access to this page by creating feature <code><%= @page.feature_flag_name %></code>
|
||||
<%= link_to "here", "/admin/feature_flags/features" %>
|
||||
<% end %>
|
||||
<br>
|
||||
</p>
|
||||
</div>
|
||||
<% end %>
|
||||
<%= form.submit class: "crayons-btn" %>
|
||||
<% end %>
|
||||
|
||||
|
|
|
|||
|
|
@ -5,4 +5,19 @@ RSpec.describe "/admin/customization/pages", type: :request do
|
|||
it_behaves_like "an InternalPolicy dependant request", Page do
|
||||
let(:request) { get admin_pages_path }
|
||||
end
|
||||
|
||||
describe "when managing feature flags" do
|
||||
it "allows tech admins to manage the feature flag for a page" do
|
||||
user = create(:user, :admin, :tech_admin)
|
||||
sign_in user
|
||||
get new_admin_page_path
|
||||
expect(response.body).to include("Feature Flag")
|
||||
end
|
||||
|
||||
it "does not allow non tech admins to manage the feature flag for a page" do
|
||||
sign_in create(:user, :admin)
|
||||
get new_admin_page_path
|
||||
expect(response.body).not_to include("Feature Flag")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue