From d489697a50d95b312a06eb28e64a271f75de61bd Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Sat, 2 Feb 2019 02:52:45 +0500 Subject: [PATCH] Edit Account#public_name --- app/policies/settings/profile_policy.rb | 2 +- app/views/settings/profiles/edit.html.erb | 1 + spec/requests/settings/profile/update_spec.rb | 12 ++++++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/policies/settings/profile_policy.rb b/app/policies/settings/profile_policy.rb index f89b1d0..231420e 100644 --- a/app/policies/settings/profile_policy.rb +++ b/app/policies/settings/profile_policy.rb @@ -6,6 +6,6 @@ class Settings::ProfilePolicy < ApplicationPolicy end def permitted_attributes_for_update - %i[username biography] + %i[username public_name biography] end end diff --git a/app/views/settings/profiles/edit.html.erb b/app/views/settings/profiles/edit.html.erb index 19646af..91bbc3e 100644 --- a/app/views/settings/profiles/edit.html.erb +++ b/app/views/settings/profiles/edit.html.erb @@ -10,6 +10,7 @@
<%= f.input :username, required: true %> + <%= f.input :public_name %> <%= f.input :biography %>
diff --git a/spec/requests/settings/profile/update_spec.rb b/spec/requests/settings/profile/update_spec.rb index 2e13e31..987242e 100644 --- a/spec/requests/settings/profile/update_spec.rb +++ b/spec/requests/settings/profile/update_spec.rb @@ -7,8 +7,9 @@ RSpec.describe 'PATCH/PUT /settings/profile' do let :account_attributes do { - username: Faker::Internet.username(3..36, %w[_]), - biography: Faker::Lorem.paragraph, + username: Faker::Internet.username(3..36, %w[_]), + public_name: Faker::Name.name, + biography: Faker::Lorem.paragraph, } end @@ -36,6 +37,13 @@ RSpec.describe 'PATCH/PUT /settings/profile' do .to(account_attributes[:username]) end + specify do + expect { make_request }.to \ + change { current_account.reload.public_name } + .from(current_account.public_name) + .to(account_attributes[:public_name]) + end + specify do expect { make_request }.to \ change { current_account.reload.biography }