Skip to content

Commit

Permalink
Ignore dimensions extraction errors by default
Browse files Browse the repository at this point in the history
This was the default behaviour before we added the :on_error handler, so
we keep it. In Shrine 3.0 dimensions extraction exceptions will trigger
a warning by default.
  • Loading branch information
janko committed Aug 9, 2019
1 parent 4945c45 commit 9834bfe
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## HEAD

* `store_dimensions` – Ignore dimensions extraction errors by default (@janko)

* `file_system` – Un-deprecate `FileSystem#upload` receiving unrecognized options (@janko)

## 2.19.2 (2018-07-25)
Expand Down
2 changes: 1 addition & 1 deletion lib/shrine/plugins/store_dimensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module StoreDimensions
end

def self.configure(uploader, opts = {})
uploader.opts[:store_dimensions] ||= { analyzer: :fastimage, on_error: :warn, log_subscriber: LOG_SUBSCRIBER }
uploader.opts[:store_dimensions] ||= { analyzer: :fastimage, on_error: :ignore, log_subscriber: LOG_SUBSCRIBER }
uploader.opts[:store_dimensions].merge!(opts)

# resolve error strategy
Expand Down
12 changes: 3 additions & 9 deletions test/plugin/store_dimensions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
end

it "returns nil for non-images" do
assert_logged /SHRINE WARNING: Error occurred/ do
assert_nil @shrine.extract_dimensions(fakeio)
end
assert_nil @shrine.extract_dimensions(fakeio)
end
end

Expand All @@ -43,9 +41,7 @@
end

it "returns nil for non-images" do
assert_logged /SHRINE WARNING: Error occurred/ do
assert_nil @shrine.extract_dimensions(fakeio)
end
assert_nil @shrine.extract_dimensions(fakeio)
end
end unless ENV["CI"]

Expand All @@ -64,9 +60,7 @@
end

it "returns nil for non-images" do
assert_logged /SHRINE WARNING: Error occurred/ do
assert_nil @shrine.extract_dimensions(fakeio)
end
assert_nil @shrine.extract_dimensions(fakeio)
end
end unless ENV["CI"]

Expand Down

0 comments on commit 9834bfe

Please sign in to comment.