Commit d793bceb90c3e2a7e2302531a69d6e693e66ae78
Exists in
master
and in
4 other branches
Merge pull request #5733 from bke-drewb/issue-5716
Issue 5716 - Allow removal of avatar
Showing
8 changed files
with
66 additions
and
4 deletions
Show diff stats
CHANGELOG
app/assets/stylesheets/sections/profile.scss
app/views/profiles/show.html.haml
| ... | ... | @@ -59,9 +59,14 @@ |
| 59 | 59 | .clearfix |
| 60 | 60 | .profile-avatar-form-option |
| 61 | 61 | %p.light |
| 62 | - You can upload an avatar here | |
| 63 | - %br | |
| 64 | - or change it at #{link_to "gravatar.com", "http://gravatar.com"} | |
| 62 | + - if @user.avatar? | |
| 63 | + You can change your avatar here | |
| 64 | + %br | |
| 65 | + or remove the current avatar to revert to #{link_to "gravatar.com", "http://gravatar.com"} | |
| 66 | + - else | |
| 67 | + You can upload an avatar here | |
| 68 | + %br | |
| 69 | + or change it at #{link_to "gravatar.com", "http://gravatar.com"} | |
| 65 | 70 | %hr |
| 66 | 71 | %a.choose-btn.btn.btn-small.js-choose-user-avatar-button |
| 67 | 72 | %i.icon-paper-clip |
| ... | ... | @@ -70,6 +75,8 @@ |
| 70 | 75 | %span.file_name.js-avatar-filename File name... |
| 71 | 76 | = f.file_field :avatar, class: "js-user-avatar-input hide" |
| 72 | 77 | %span.help-block The maximum file size allowed is 100KB. |
| 78 | + - if @user.avatar? | |
| 79 | + = link_to 'Remove avatar', profile_avatar_path, confirm: "Avatar will be removed. Are you sure?", method: :delete, class: "btn btn-remove remove_avatar" | |
| 73 | 80 | |
| 74 | 81 | .form-actions |
| 75 | 82 | - = f.submit 'Save changes', class: "btn btn-save" |
| 83 | + = f.submit 'Save changes', class: "btn btn-save" | |
| 76 | 84 | \ No newline at end of file | ... | ... |
config/routes.rb
features/profile/profile.feature
| ... | ... | @@ -26,6 +26,14 @@ Feature: Profile |
| 26 | 26 | Given I visit profile page |
| 27 | 27 | Then I change my avatar |
| 28 | 28 | And I should see new avatar |
| 29 | + And I should see the "Remove avatar" button | |
| 30 | + | |
| 31 | + Scenario: I remove my avatar | |
| 32 | + Given I visit profile page | |
| 33 | + And I have an avatar | |
| 34 | + When I remove my avatar | |
| 35 | + Then I should see my gravatar | |
| 36 | + And I should not see the "Remove avatar" button | |
| 29 | 37 | |
| 30 | 38 | Scenario: My password is expired |
| 31 | 39 | Given my password is expired | ... | ... |
features/steps/profile/profile.rb
| ... | ... | @@ -31,6 +31,29 @@ class Profile < Spinach::FeatureSteps |
| 31 | 31 | @user.avatar.url.should == "/uploads/user/avatar/#{ @user.id }/gitlab_logo.png" |
| 32 | 32 | end |
| 33 | 33 | |
| 34 | + step 'I should see the "Remove avatar" button' do | |
| 35 | + page.should have_link("Remove avatar") | |
| 36 | + end | |
| 37 | + | |
| 38 | + step 'I have an avatar' do | |
| 39 | + attach_file(:user_avatar, File.join(Rails.root, 'public', 'gitlab_logo.png')) | |
| 40 | + click_button "Save changes" | |
| 41 | + @user.reload | |
| 42 | + end | |
| 43 | + | |
| 44 | + step 'I remove my avatar' do | |
| 45 | + click_link "Remove avatar" | |
| 46 | + @user.reload | |
| 47 | + end | |
| 48 | + | |
| 49 | + step 'I should see my gravatar' do | |
| 50 | + @user.avatar?.should be_false | |
| 51 | + end | |
| 52 | + | |
| 53 | + step 'I should not see the "Remove avatar" button' do | |
| 54 | + page.should_not have_link("Remove avatar") | |
| 55 | + end | |
| 56 | + | |
| 34 | 57 | step 'I try change my password w/o old one' do |
| 35 | 58 | within '.update-password' do |
| 36 | 59 | fill_in "user_password", with: "22233344" | ... | ... |
spec/routing/routing_spec.rb
| ... | ... | @@ -185,6 +185,13 @@ describe Profiles::KeysController, "routing" do |
| 185 | 185 | end |
| 186 | 186 | end |
| 187 | 187 | |
| 188 | +# profile_avatar DELETE /profile/avatar(.:format) profiles/avatars#destroy | |
| 189 | +describe Profiles::AvatarsController, "routing" do | |
| 190 | + it "to #destroy" do | |
| 191 | + delete("/profile/avatar").should route_to('profiles/avatars#destroy') | |
| 192 | + end | |
| 193 | +end | |
| 194 | + | |
| 188 | 195 | # dashboard GET /dashboard(.:format) dashboard#show |
| 189 | 196 | # dashboard_issues GET /dashboard/issues(.:format) dashboard#issues |
| 190 | 197 | # dashboard_merge_requests GET /dashboard/merge_requests(.:format) dashboard#merge_requests | ... | ... |