BUGFIX: Allow image upload even if no existing image (#12312)
* Allow image upload even if no existing image Allow profile image upload even if there's no profile image attached. * Add specs to ensure profile image field is there Specs to ensure that the profile image upload field is always available wether the user has a profile picture or not.
This commit is contained in:
parent
ce018b885e
commit
fe00bcacf9
2 changed files with 23 additions and 1 deletions
|
|
@ -41,8 +41,8 @@
|
|||
<div class="flex items-center">
|
||||
<% if @user.profile_image_url.present? %>
|
||||
<span class="crayons-avatar crayons-avatar--xl mr-2"><img alt="<%= @user.username %> profile image" src="<%= Images::Profile.call(@user.profile_image_url, length: 50) %>" class="crayons-avatar__image" /></span>
|
||||
<%= f.file_field "user[profile_image]", accept: "image/*", class: "crayons-card crayons-card--secondary p-3 flex items-center flex-1 w-100" %>
|
||||
<% end %>
|
||||
<%= f.file_field "user[profile_image]", accept: "image/*", class: "crayons-card crayons-card--secondary p-3 flex items-center flex-1 w-100" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -202,6 +202,28 @@ RSpec.describe "UserSettings", type: :request do
|
|||
end
|
||||
end
|
||||
|
||||
describe "GET /settings/profile" do
|
||||
before { sign_in user }
|
||||
|
||||
context "when user has profile image" do
|
||||
it "displays profile image upload input" do
|
||||
get user_settings_path(:profile)
|
||||
|
||||
expect(response.body).to include("user[profile_image]")
|
||||
end
|
||||
end
|
||||
|
||||
context "when user does not have a profile image" do
|
||||
let(:user) { create(:user, profile_image: nil) }
|
||||
|
||||
it "displays profile image upload input" do
|
||||
get user_settings_path(:profile)
|
||||
|
||||
expect(response.body).to include("user[profile_image]")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "PUT /update/:id" do
|
||||
before { sign_in user }
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue