Skip to content

Commit

Permalink
AO3-6608 Delete Alt Text With Pseud Icon (#4765)
Browse files Browse the repository at this point in the history
* AO3-6608 - fix the bug

* AO3-6608 - write a test

* AO3-6608 - make rubocop happy

* AO3-6608 - address pr feedback

* AO3-6608 - rubocop

* Update app/models/pseud.rb
  • Loading branch information
smclairecarden authored Apr 4, 2024
1 parent dbcbef8 commit 61142b1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/models/pseud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,10 @@ def delete_icon
alias_method :delete_icon?, :delete_icon

def clear_icon
self.icon = nil if delete_icon? && !icon.dirty?
return unless delete_icon?

self.icon = nil unless icon.dirty?
self.icon_alt_text = nil
end

#################################
Expand Down
12 changes: 12 additions & 0 deletions features/collections/icon.feature
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,15 @@ Feature: User icons
When I delete the icon from the collection "Pretty"
Then I should see "Collection was successfully updated."
And the "Pretty" collection should not have an icon

Scenario: Users can delete icon and alt text

Given I have an icon uploaded
When I follow "Edit Pseud"
And I fill in "pseud_icon_alt_text" with "Some test description"
And I press "Update"
Then I should see the image "alt" text "Some test description"
When I delete the icon from my pseud
Then I should see "Pseud was successfully updated."
When I follow "Edit Pseud"
Then I should see the icon and alt text boxes are blank
11 changes: 11 additions & 0 deletions features/step_definitions/icon_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@
step %{I press "Update"}
end

When "I delete the icon from my pseud" do
visit edit_user_pseud_path(User.current_user, User.current_user.default_pseud)
check("pseud_delete_icon")
step %{I press "Update"}
end

Then /^the "([^"]*)" collection should have an icon$/ do |title|
collection = Collection.find_by(title: title)
assert !collection.icon_file_name.blank?
Expand All @@ -45,3 +51,8 @@
end

### THEN

Then "I should see the icon and alt text boxes are blank" do
expect(find("#pseud_icon").value).to be_blank
expect(find("#pseud_icon_alt_text").value).to be_nil
end

0 comments on commit 61142b1

Please sign in to comment.