2020-01-03 02:44:06 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
2024-09-04 01:12:25 -04:00
|
|
|
RSpec.describe 'Profile' do
|
2020-01-03 02:44:06 +01:00
|
|
|
include ProfileStories
|
|
|
|
|
2024-06-03 05:15:58 -04:00
|
|
|
let(:local_domain) { Rails.configuration.x.local_domain }
|
2020-01-03 02:44:06 +01:00
|
|
|
|
2023-02-18 16:59:00 -05:00
|
|
|
before do
|
2020-01-03 02:44:06 +01:00
|
|
|
as_a_logged_in_user
|
2024-10-23 09:31:03 -04:00
|
|
|
Fabricate(:user, account: Fabricate(:account, username: 'alice'))
|
2020-01-03 02:44:06 +01:00
|
|
|
end
|
|
|
|
|
2024-10-23 09:31:03 -04:00
|
|
|
it 'I can view public account page for Alice' do
|
2020-01-03 02:44:06 +01:00
|
|
|
visit account_path('alice')
|
|
|
|
|
2025-01-22 13:50:15 -05:00
|
|
|
expect(page)
|
|
|
|
.to have_title("alice (@alice@#{local_domain})")
|
2020-01-03 02:44:06 +01:00
|
|
|
end
|
|
|
|
|
2023-02-18 16:59:00 -05:00
|
|
|
it 'I can change my account' do
|
2020-01-03 02:44:06 +01:00
|
|
|
visit settings_profile_path
|
2022-10-20 14:35:29 +02:00
|
|
|
|
2020-01-03 02:44:06 +01:00
|
|
|
fill_in 'Display name', with: 'Bob'
|
|
|
|
fill_in 'Bio', with: 'Bob is silent'
|
|
|
|
|
2025-01-22 13:50:15 -05:00
|
|
|
fill_in 'account_fields_attributes_0_name', with: 'Personal Website'
|
|
|
|
fill_in 'account_fields_attributes_0_value', with: 'https://host.example/personal'
|
|
|
|
|
|
|
|
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
|
2022-10-20 14:35:29 +02:00
|
|
|
first('button[type=submit]').click
|
2025-01-22 13:50:15 -05:00
|
|
|
end
|
2020-01-03 02:44:06 +01:00
|
|
|
|
2025-01-22 13:50:15 -05:00
|
|
|
def change_account_fields
|
|
|
|
change { bob.account.reload.fields }
|
|
|
|
.from([])
|
|
|
|
.to(
|
|
|
|
contain_exactly(
|
|
|
|
be_a(Account::Field),
|
|
|
|
be_a(Account::Field)
|
|
|
|
)
|
|
|
|
)
|
2020-01-03 02:44:06 +01:00
|
|
|
end
|
|
|
|
end
|