Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AO3-6608 Delete Alt Text With Pseud Icon #4765

Merged
merged 7 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading