-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chore: tests covering image upload problems (#1458)
Fixes #1428: Image uploading feedback - verify the error box is present when problems exist - verify the image field has feedback text - fixes code in app that does not express this behavior correctly Pages covered: - site: new, edit - partner: new, edit - article: new, edit - user: new, edit, profile
- Loading branch information
1 parent
4af2a54
commit 55ff9b4
Showing
8 changed files
with
216 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
<% if properties[:object].errors.any? %> | ||
<div class="card text-white bg-danger mb-3" > | ||
<div class="card-header"><h6><%= pluralize(properties[:object].errors.count, "error") %> prohibited this <%= properties[:object].class.name %> from being saved</h6></div> | ||
<div class="card-body"> | ||
<div class="card-text"> | ||
<ul class="list-unstyle mb-0"> | ||
<% properties[:object].errors.full_messages.each do |message| %> | ||
<li><%= message %></li> | ||
<% end %> | ||
</ul> | ||
<div id='form-errors' class="card text-white bg-danger mb-3" > | ||
<div class="card-header"><h6><%= pluralize(properties[:object].errors.count, "error") %> prohibited this <%= properties[:object].class.name %> from being saved</h6></div> | ||
<div class="card-body"> | ||
<div class="card-text"> | ||
<ul class="list-unstyle mb-0"> | ||
<% properties[:object].errors.full_messages.each do |message| %> | ||
<li><%= message %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -236,4 +236,64 @@ class AdminUserIntegrationTest < ActionDispatch::IntegrationTest | |
|
||
assert_select "p.has-no-admin-rights-warning" | ||
end | ||
|
||
test 'new user avatar upload problem feedback' do | ||
sign_in @root | ||
|
||
new_user_params = { | ||
email: '[email protected]', | ||
role: 'root', | ||
avatar: fixture_file_upload("bad-cat-picture.bmp"), | ||
} | ||
|
||
post admin_users_path, params: { user: new_user_params } | ||
assert_not response.redirect? | ||
|
||
assert_select "h6", text: "1 error prohibited this User from being saved" | ||
|
||
# top of page form error box | ||
assert_select '#form-errors li', text: "Avatar You are not allowed to upload \"bmp\" files, allowed types: jpg, jpeg, png" | ||
|
||
assert_select 'form .user_avatar .invalid-feedback', text: "Avatar You are not allowed to upload \"bmp\" files, allowed types: jpg, jpeg, png" | ||
end | ||
|
||
test 'update user avatar upload problem feedback' do | ||
sign_in @root | ||
|
||
user_params = { | ||
email: @root.email, | ||
role: @root.role, | ||
avatar: fixture_file_upload("bad-cat-picture.bmp"), | ||
} | ||
|
||
put admin_user_path(@root), params: { user: user_params } | ||
assert_not response.redirect? | ||
|
||
assert_select "h6", text: "1 error prohibited this User from being saved" | ||
|
||
# top of page form error box | ||
assert_select '#form-errors li', text: "Avatar You are not allowed to upload \"bmp\" files, allowed types: jpg, jpeg, png" | ||
|
||
assert_select 'form .user_avatar .invalid-feedback', text: "Avatar You are not allowed to upload \"bmp\" files, allowed types: jpg, jpeg, png" | ||
end | ||
|
||
test 'update profile avatar upload problem feedback' do | ||
sign_in @root | ||
|
||
user_params = { | ||
email: @root.email, | ||
avatar: fixture_file_upload("bad-cat-picture.bmp"), | ||
} | ||
|
||
patch update_profile_admin_user_path(@root), params: { user: user_params } | ||
assert_not response.redirect? | ||
|
||
assert_select "h6", text: "1 error prohibited this User from being saved" | ||
|
||
# top of page form error box | ||
assert_select '#form-errors li', text: "Avatar You are not allowed to upload \"bmp\" files, allowed types: jpg, jpeg, png" | ||
|
||
assert_select 'form .user_avatar .invalid-feedback', text: "Avatar You are not allowed to upload \"bmp\" files, allowed types: jpg, jpeg, png" | ||
end | ||
|
||
end |