From 9605317887a2203b7b1a03750a58b51afcb8452b Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Fri, 1 Feb 2019 09:23:01 +0500 Subject: [PATCH] Edit Account#biography --- app/policies/settings/profile_policy.rb | 2 +- app/views/settings/profiles/edit.html.erb | 1 + factories/accounts.rb | 4 +++- spec/requests/settings/profile/update_spec.rb | 10 +++++++++- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/policies/settings/profile_policy.rb b/app/policies/settings/profile_policy.rb index 2e577bf..f89b1d0 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] + %i[username biography] end end diff --git a/app/views/settings/profiles/edit.html.erb b/app/views/settings/profiles/edit.html.erb index 2bde651..19646af 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 :biography %>
diff --git a/factories/accounts.rb b/factories/accounts.rb index 16fd1b8..845c99b 100644 --- a/factories/accounts.rb +++ b/factories/accounts.rb @@ -1,7 +1,9 @@ # frozen_string_literal: true FactoryBot.define do - factory :guest_account, class: Account + factory :guest_account, class: Account do + biography { Faker::Lorem.paragraph } + end factory :usual_account, parent: :guest_account do association :user diff --git a/spec/requests/settings/profile/update_spec.rb b/spec/requests/settings/profile/update_spec.rb index 74b3010..2e13e31 100644 --- a/spec/requests/settings/profile/update_spec.rb +++ b/spec/requests/settings/profile/update_spec.rb @@ -7,7 +7,8 @@ RSpec.describe 'PATCH/PUT /settings/profile' do let :account_attributes do { - username: Faker::Internet.username(3..36, %w[_]), + username: Faker::Internet.username(3..36, %w[_]), + biography: Faker::Lorem.paragraph, } end @@ -35,6 +36,13 @@ RSpec.describe 'PATCH/PUT /settings/profile' do .to(account_attributes[:username]) end + specify do + expect { make_request }.to \ + change { current_account.reload.biography } + .from(current_account.biography) + .to(account_attributes[:biography]) + end + context 'after request' do before { make_request }