Skip to content

AO3-4547 Allow banner updates WITHOUT turning banner back on #2435

Merged
merged 6 commits into from May 28, 2016

4 participants

@sarken
Organization for Transformative Works member
sarken commented Apr 11, 2016

https://otwarchive.atlassian.net/browse/AO3-4547

We want to make it so admins can fix typos or update fundraising totals in admin banners without turning the banner back on instead of having to ask poor james to do it from the console.

@sarken sarken and 1 other commented on an outdated diff Apr 11, 2016
app/controllers/admin/banners_controller.rb
@@ -43,7 +43,10 @@ def create
def update
@admin_banner = AdminBanner.find(params[:id])
- if @admin_banner.update_attributes(params[:admin_banner])
+ if @admin_banner.update_attributes(params[:admin_banner]) && params[:admin_banner_minor_edit]
@sarken
Organization for Transformative Works member
sarken added a note Apr 11, 2016

There may be a neater way to do this. If so, I am all ears!

@shalott
Organization for Transformative Works member
shalott added a note Apr 12, 2016

Actually, doing it this way you'll be updating_attributes twice if it is not a minor edit. I suggest you flip it, ie:

if !@admin_banner.update_attributes(params[:admin_banner])
  render action: 'edit'
elsif params[:admin_banner_minor_edit]
  minor edit code here
else
  normal success code here
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@shalott shalott commented on an outdated diff Apr 12, 2016
features/other_a/banner_general.feature
+Scenario: Admin should not have option to make minor updates on banner that is not active
+ Given there are no banners
+ And an admin creates a banner
+ When I am logged in as an admin
+ And I am on the admin_banners page
+ And I follow "Edit"
+ Then I should not see "This is a minor update (Do not turn the banner back on for users who have dismissed it)"
+
+Scenario: Admin can make minor changes to the text of an active banner without turning it back on for users who have already dismissed it
+ Given there are no banners
+ And an admin creates an active banner
+ And I am logged in as "banner_tester_3" with password "nobanners"
+ And I set my preferences to turn off the banner showing on every page
+ And an admin makes a minor edit to the active banner
+ When I am logged in as "banner_tester_3" with password "nobanners"
+ Then I should not see "This is some banner text!"
@shalott
Organization for Transformative Works member
shalott added a note Apr 12, 2016

This is nitpicky, but ideally you'd have the actual text in one file. What I mean is, either your earlier step should be "And an admin adds "This is some banner text!" to the active banner as a minor edit" and change the step definition to take custom text, or you should have this step should be "Then I should not see the minor edit" and make the step definition in the banner_steps file look for the text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@sarken
Organization for Transformative Works member
sarken commented Apr 17, 2016

Tests updated, btw! I forgot to comment, whoops.

@zz9pzza zz9pzza merged commit a0c94e3 into otwcode:master May 28, 2016

1 check passed

Details continuous-integration/travis-ci/pr The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.