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

Remove unused Picture#security_token method #1614

Merged
merged 1 commit into from
Aug 19, 2019
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
21 changes: 0 additions & 21 deletions app/models/alchemy/picture.rb
Original file line number Diff line number Diff line change
Expand Up @@ -246,26 +246,5 @@ def deletable?
def image_file_dimensions
"#{image_file_width}x#{image_file_height}"
end

# Returns a security token for signed picture rendering requests.
#
# Pass a params hash containing:
#
# size [String] (Optional)
# crop [Boolean] (Optional)
# crop_from [String] (Optional)
# crop_size [String] (Optional)
# quality [Integer] (Optional)
#
# to sign them.
#
def security_token(params = {})
params = params.dup.stringify_keys
params.update({
'crop' => params['crop'] ? 'crop' : nil,
'id' => id
})
PictureAttributes.secure(params)
end
end
end
28 changes: 0 additions & 28 deletions lib/alchemy/picture_attributes.rb

This file was deleted.

1 change: 0 additions & 1 deletion lib/alchemy_cms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ module Alchemy
require_relative 'alchemy/page_layout'
require_relative 'alchemy/paths'
require_relative 'alchemy/permissions'
require_relative 'alchemy/picture_attributes'
require_relative 'alchemy/sass_support'
require_relative 'alchemy/ssl_protection'
require_relative 'alchemy/resource'
Expand Down
32 changes: 0 additions & 32 deletions spec/models/alchemy/picture_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,38 +111,6 @@ module Alchemy
end
end

describe '#security_token' do
before { @pic = stub_model(Picture, id: 1) }

it "should return a sha1 hash" do
expect(@pic.security_token).to match(/\b([a-f0-9]{16})\b/)
end

it "should return a 16 chars long hash" do
@pic.security_token.length == 16
end

it "should convert crop true value into string" do
digest = PictureAttributes.secure({id: @pic.id, crop: 'crop'})
expect(@pic.security_token(crop: true)).to eq(digest)
end

it "should always include picture id" do
digest = PictureAttributes.secure({id: @pic.id})
expect(@pic.security_token).to eq(digest)
end

it "should remove all not suitable options" do
digest = PictureAttributes.secure({id: @pic.id})
expect(@pic.security_token({foo: 'baz'})).to eq(digest)
end

it "should remove all option values that have nil values" do
digest = PictureAttributes.secure({id: @pic.id})
expect(@pic.security_token({crop: nil})).to eq(digest)
end
end

describe ".search_by" do
subject(:search_by) { Picture.search_by(params, query, per_page) }

Expand Down