Skip to content

Commit

Permalink
Add tests to PR #726 that change one up and down arrow only
Browse files Browse the repository at this point in the history
TODO: Avoid cloning and restoring Ransack.options in each test.
  • Loading branch information
jonatack committed Sep 29, 2016
1 parent f73dd6a commit f75504f
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
26 changes: 25 additions & 1 deletion spec/mongoid/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,31 @@ module Ransack
expect(Ransack.options[:down_arrow]).to eq '▲'
end

it 'changes default arrow strings' do
it 'changes the default value for the up arrow only' do
before = Ransack.options.clone
up_value, down_value = 'U+02193', Ransack.options[:down_arrow]

Ransack.configure { |c| c.custom_arrows = { up_arrow: up_value } }

expect(Ransack.options[:up_arrow]).to eq up_value
expect(Ransack.options[:down_arrow]).to eq down_value

Ransack.options = before
end

it 'changes the default value for the down arrow only' do
before = Ransack.options.clone
up_value, down_value = Ransack.options[:up_arrow], '<i class="down"></i>'

Ransack.configure { |c| c.custom_arrows = { down_arrow: down_value } }

expect(Ransack.options[:up_arrow]).to eq up_value
expect(Ransack.options[:down_arrow]).to eq down_value

Ransack.options = before
end

it 'changes the default value for both arrows' do
before = Ransack.options.clone
up_value, down_value = '<i class="fa fa-long-arrow-up"></i>', 'U+02193'

Expand Down
26 changes: 25 additions & 1 deletion spec/ransack/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,31 @@ module Ransack
expect(Ransack.options[:down_arrow]).to eq '&#9650;'
end

it 'changes default arrow strings' do
it 'changes the default value for the up arrow only' do
before = Ransack.options.clone
up_value, down_value = 'U+02193', Ransack.options[:down_arrow]

Ransack.configure { |c| c.custom_arrows = { up_arrow: up_value } }

expect(Ransack.options[:up_arrow]).to eq up_value
expect(Ransack.options[:down_arrow]).to eq down_value

Ransack.options = before
end

it 'changes the default value for the down arrow only' do
before = Ransack.options.clone
up_value, down_value = Ransack.options[:up_arrow], '<i class="down"></i>'

Ransack.configure { |c| c.custom_arrows = { down_arrow: down_value } }

expect(Ransack.options[:up_arrow]).to eq up_value
expect(Ransack.options[:down_arrow]).to eq down_value

Ransack.options = before
end

it 'changes the default value for both arrows' do
before = Ransack.options.clone
up_value, down_value = '<i class="fa fa-long-arrow-up"></i>', 'U+02193'

Expand Down

0 comments on commit f75504f

Please sign in to comment.