diff --git a/app/controllers/settings/profiles_controller.rb b/app/controllers/settings/profiles_controller.rb index 2d80998968..458f4148cc 100644 --- a/app/controllers/settings/profiles_controller.rb +++ b/app/controllers/settings/profiles_controller.rb @@ -20,7 +20,7 @@ class Settings::ProfilesController < Settings::BaseController private def account_params - params.expect(account: [:display_name, :note, :avatar, :header, :bot, fields_attributes: [:name, :value]]) + params.expect(account: [:display_name, :note, :avatar, :header, :bot, fields_attributes: [[:name, :value]]]) end def set_account diff --git a/spec/system/profile_spec.rb b/spec/system/profile_spec.rb index a05a146fef..f9449b52c3 100644 --- a/spec/system/profile_spec.rb +++ b/spec/system/profile_spec.rb @@ -5,8 +5,6 @@ require 'rails_helper' RSpec.describe 'Profile' do include ProfileStories - subject { page } - let(:local_domain) { Rails.configuration.x.local_domain } before do @@ -17,7 +15,8 @@ RSpec.describe 'Profile' do it 'I can view public account page for Alice' do visit account_path('alice') - expect(subject).to have_title("alice (@alice@#{local_domain})") + expect(page) + .to have_title("alice (@alice@#{local_domain})") end it 'I can change my account' do @@ -26,8 +25,31 @@ RSpec.describe 'Profile' do fill_in 'Display name', with: 'Bob' fill_in 'Bio', with: 'Bob is silent' - first('button[type=submit]').click + fill_in 'account_fields_attributes_0_name', with: 'Personal Website' + fill_in 'account_fields_attributes_0_value', with: 'https://host.example/personal' - expect(subject).to have_content 'Changes successfully saved!' + fill_in 'account_fields_attributes_1_name', with: 'Professional Biography' + fill_in 'account_fields_attributes_1_value', with: 'https://host.example/pro' + + expect { submit_form } + .to change { bob.account.reload.display_name }.to('Bob') + .and(change_account_fields) + expect(page) + .to have_content 'Changes successfully saved!' + end + + def submit_form + first('button[type=submit]').click + end + + def change_account_fields + change { bob.account.reload.fields } + .from([]) + .to( + contain_exactly( + be_a(Account::Field), + be_a(Account::Field) + ) + ) end end