Skip to content

Commit

Permalink
AO3-6486 Make sure the proper options are shown or hidden
Browse files Browse the repository at this point in the history
  • Loading branch information
sarken committed Apr 1, 2024
1 parent 54076bf commit d1839d9
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 11 deletions.
12 changes: 8 additions & 4 deletions app/views/admin/banners/_navigation.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<ul class="navigation actions">
<li><%= span_if_current ts('Banners'), admin_banners_path %></li>
<li><%= span_if_current ts('New Banner'), new_admin_banner_path %></li>
<li><%= span_if_current t(".index"), admin_banners_path %></li>
<% if policy(AdminBanner).new? %>
<li><%= span_if_current t(".new"), new_admin_banner_path %></li>
<% end %>
<% if params[:id] %>
<li><%= span_if_current ts('Edit Banner'), edit_admin_banner_path(@admin_banner) %></li>
<li><%= link_to ts('Delete Banner'), confirm_delete_admin_banner_path(@admin_banner), data: {confirm: ts('Are you sure you want to delete this banner?')} %></li>
<li><%= span_if_current t(".edit"), edit_admin_banner_path(@admin_banner) %></li>
<% if policy(AdminBanner).destroy? %>
<li><%= link_to t(".delete"), confirm_delete_admin_banner_path(@admin_banner), data: { confirm: t(".confirm_delete") } %></li>
<% end %>
<% end %>
</ul>
16 changes: 9 additions & 7 deletions app/views/admin/banners/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="admin">
<!--Descriptive page name, messages and instructions-->
<h2 class="heading"><%= ts('Banners') %></h2>
<h2 class="heading"><%= t(".page_heading") %></h2>
<!--/descriptions-->

<!--subnav-->
Expand All @@ -13,20 +13,22 @@
<ul class="banners index group">
<% for admin_banner in @admin_banners %>
<li class="blurb">
<%= render 'banner', admin_banner: admin_banner %>
<%= render "banner", admin_banner: admin_banner %>
<ul class="actions">
<% if admin_banner.active? %>
<li>
<span class="active current"><%= ts('Active') %></span>
<span class="active current"><%= t(".actions.active") %></span>
</li>
<% end %>
</li>
<li>
<%= link_to ts('Edit'), edit_admin_banner_path(admin_banner) %>
</li>
<li>
<%= link_to ts('Delete'), confirm_delete_admin_banner_path(admin_banner), data: {confirm: ts('Are you sure you want to delete this banner?')} %>
<%= link_to t(".actions.edit"), edit_admin_banner_path(admin_banner) %>
</li>
<% if policy(AdminBanner).destroy? %>
<li>
<%= link_to t(".actions.delete"), confirm_delete_admin_banner_path(admin_banner), data: { confirm: t(".actions.confirm_delete") } %>
</li>
<% end %>
</ul>
</li>
<% end %>
Expand Down
14 changes: 14 additions & 0 deletions config/locales/views/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,20 @@ en:
required: Required when adding or removing a warning or suspension to an account.
submit: Update
heading: Record Warnings, Suspensions, or Notes
banners:
index:
actions:
active: Active
confirm_delete: Are you sure you want to delete this banner?
delete: Delete
edit: Edit
page_heading: Banners
navigation:
confirm_delete: Are you sure you want to delete this banner?
delete: Delete Banner
edit: Edit Banner
index: Banners
new: New Banner
blacklist:
emails_found:
one: one email found
Expand Down
22 changes: 22 additions & 0 deletions features/other_a/banner_general.feature
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,25 @@ Scenario: Admin can make minor changes to the text of an active banner without t
Then I should see the banner with minor edits
When I am logged in as "banner_tester_4"
Then I should see the banner with minor edits

Scenario: Development & Membership admin can see edit options but not delete or create
Given an admin creates a banner
When I am logged in as a "development_and_membership" admin
And I go to the admin_banners page
Then I should see "Banners" within "#header .admin.navigation"
And I should see "Banners" within "#main .navigation.actions"
And I should see "Edit" within "#main ul.banners.index.group"
But I should not see "Delete" within "#main ul.banners.index.group"
And I should not see "New Banner" within "#main .navigation.actions"
When I follow "Edit"
Then I should not see "New Banner" within "#main .navigation.actions"
And I should not see "Delete Banner" within "#main .navigation.actions"
But I should see "Edit Banner" within "#main h2"
And I should see "Edit Banner" within "#main .navigation.actions"
When I fill in "Banner text" with "Some fun new text"
And I press "Update Banner"
Then I should see "Banner successfully updated."
And I should see "Banners" within "#main .navigation.actions"
And I should see "Edit Banner" within "#main .navigation.actions"
But I should not see "Delete Banner" within "#main .navigation.actions"
And I should not see "New Banner" within "#main .navigation.actions"

0 comments on commit d1839d9

Please sign in to comment.