Skip to content

Commit

Permalink
Fix user presenter specs
Browse files Browse the repository at this point in the history
regarding profile picture uploading issue. Active storage requires the
files to be created with factory bot instead of just build. as now the
newer version creates a signed id on create
  • Loading branch information
AlexAvlonitis committed Sep 8, 2024
1 parent 2b2bd4b commit abff15e
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ gem 'rails'
gem 'active_model_serializers'
gem 'active_storage_validations'
gem 'acts_as_votable'
gem 'aws-sdk-s3', '~> 1'
gem "aws-sdk-s3", require: false
gem 'devise'
gem 'doorkeeper', '~> 5.4'
gem 'kaminari'
Expand All @@ -21,7 +21,6 @@ gem 'greek-cities'
gem 'httparty'
gem 'mailboxer'
gem 'mailgun_rails'
gem 'pry-rails'
gem 'pundit'
gem 'rack-attack'
gem 'rack-cors', require: 'rack/cors'
Expand All @@ -32,6 +31,7 @@ gem 'stripe'

group :development, :test do
gem 'dotenv-rails'
gem 'pry-rails'
gem 'factory_bot_rails'
gem 'faker'
gem 'rspec-rails'
Expand Down
7 changes: 2 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ GEM
ffi (1.17.0-arm64-darwin)
ffi (1.17.0-x86-linux-gnu)
ffi (1.17.0-x86-linux-musl)
ffi (1.17.0-x86_64-darwin)
ffi (1.17.0-x86_64-linux-gnu)
ffi (1.17.0-x86_64-linux-musl)
globalid (1.2.1)
Expand Down Expand Up @@ -269,8 +268,6 @@ GEM
racc (~> 1.4)
nokogiri (1.16.7-x86-linux)
racc (~> 1.4)
nokogiri (1.16.7-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.16.7-x86_64-linux)
racc (~> 1.4)
orm_adapter (0.5.0)
Expand Down Expand Up @@ -432,15 +429,15 @@ PLATFORMS
x86-linux
x86-linux-gnu
x86-linux-musl
x86_64-darwin
x86_64-linux
x86_64-linux-gnu
x86_64-linux-musl

DEPENDENCIES
active_model_serializers
active_storage_validations
acts_as_votable
aws-sdk-s3 (~> 1)
aws-sdk-s3
database_cleaner
devise
doorkeeper (~> 5.4)
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ curl --request POST \
* Elastic Search ~> 7
* Imagemagick
* MySQL
* AWS S3 bucket

## Contributing

Expand Down
3 changes: 2 additions & 1 deletion app/controllers/api/v1/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ def update
self.resource = current_user

if resource.respond_to?(:unconfirmed_email)
prev_unconfirmed_email = resource.unconfirmed_email
resource.unconfirmed_email
end

if resource.update(account_update_params)
pic = account_update_params.dig(:user_detail_attributes, :profile_picture)
resource.user_detail.profile_picture.attach(pic) if pic
Expand Down
2 changes: 1 addition & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Rails.application.configure do
config.active_storage.service = :amazon
config.active_storage.service = :local

# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
Expand Down
5 changes: 2 additions & 3 deletions spec/presenters/user_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@

let(:user_detail) { FactoryBot.build(:user_detail, :profile_picture) }
let(:email_preference) do
FactoryBot.build(:email_preference, messages: email_preference_messages)
FactoryBot.create(:email_preference, messages: email_preference_messages)
end
let(:user) do
FactoryBot.build(
:user,
FactoryBot.create(:user,
is_signed_in: is_signed_in,
user_detail: user_detail,
email_preference: email_preference
Expand Down

0 comments on commit abff15e

Please sign in to comment.