Skip to content

Commit

Permalink
Merge pull request urvin-compliance#132 from yholkamp/image-data-patch
Browse files Browse the repository at this point in the history
Fix issue urvin-compliance#131 (img tag URL is resolved even when data is provided)
  • Loading branch information
goulvench committed Mar 18, 2020
2 parents 562bdc4 + 3bb318c commit edb30d0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/caracal/core/models/image_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def initialize(options={}, &block)
end

def relationship_target
image_url || image_data
image_data || image_url
end


Expand Down Expand Up @@ -115,7 +115,7 @@ def valid?
private

def option_keys
[:url, :width, :height, :align, :top, :bottom, :left, :right]
[:url, :width, :height, :align, :top, :bottom, :left, :right, :data]
end

def pixels_to_emus(value, ppi)
Expand Down
3 changes: 2 additions & 1 deletion spec/lib/caracal/core/images_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
describe '.img' do
let!(:size) { subject.contents.size }

before { subject.img 'https://www.google.com/images/srpr/logo11w.png', width: 538, height: 190 }
before { subject.img 'https://www.google.com/images/srpr/logo11w.png', width: 538, height: 190, data: "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/D/PwAHAwL/qGeMxAAAAABJRU5ErkJggg==" }

it { expect(subject.contents.size).to eq size + 1 }
it { expect(subject.contents.last).to be_a(Caracal::Core::Models::ImageModel) }
it { expect(subject.contents.last.image_data).to be_truthy}
end

end
Expand Down

0 comments on commit edb30d0

Please sign in to comment.