Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image code tweaks #6509

Merged
merged 3 commits into from
Dec 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions app/models/spree/image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,24 @@ def mini_url
end

def find_dimensions
temporary = attachment.queued_for_write[:original]
filename = temporary.path unless temporary.nil?
filename = attachment.path if filename.blank?
geometry = Paperclip::Geometry.from_file(filename)
return if attachment.errors.present?

geometry = Paperclip::Geometry.from_file(local_filename_of_original)

self.attachment_width = geometry.width
self.attachment_height = geometry.height
end

def local_filename_of_original
temporary = attachment.queued_for_write[:original]

if temporary&.path.present?
temporary.path
else
attachment.path
end
end

# if there are errors from the plugin, then add a more meaningful message
def no_attachment_errors
return if attachment.errors.empty?
Expand Down
8 changes: 5 additions & 3 deletions spec/lib/tasks/users_rake_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
require 'rake'

describe 'users.rake' do
before(:all) do
Rake.application.rake_require 'tasks/users'
Rake::Task.define_task(:environment)
end

describe ':remove_enterprise_limit' do
context 'when the user exists' do
it 'sets the enterprise_limit to the maximum integer' do
Rake.application.rake_require 'tasks/users'
Rake::Task.define_task(:environment)

max_integer = 2_147_483_647
user = create(:user)

Expand Down