Sha256: bb0863917c5c17e00ddc96779495bb7867518b7124bba7c263cf65f7e531a2c7
Contents?: true
Size: 1.39 KB
Versions: 1
Compression:
Stored size: 1.39 KB
Contents
require 'spec_helper' require 'sorting_helper' describe SortingHelper, type: [:helper] do before do def controller.default_url_options { controller: :application } end end describe '#sorting_url' do it 'pass reversed sorting url and current direction to given block' do controller.params[:sort] = '-column' helper.sorting_url(:column) do |url, direction| expect(url).to eq('/?sort=column') expect(direction).to eq(:desc) end controller.params[:sort] = 'column' helper.sorting_url(:column) do |url, direction| expect(url).to eq('/?sort=-column') expect(direction).to eq(:asc) end end it 'default direction is asc' do helper.sorting_url(:column) do |url, direction| expect(url).to eq('/?sort=-column') expect(direction).to eq(:asc) end end end describe '#sorting_link' do it 'generates html link for given column and label' do expect(helper.sorting_link(:column, 'label')).to eq('<a href="/?sort=-column">label</a>') end it 'inverts sorting for current column' do controller.params[:sort] = 'column' expect(helper.sorting_link(:column, 'label')).to eq('<a href="/?sort=-column">label</a> ▴') controller.params[:sort] = '-column' expect(helper.sorting_link(:column, 'label')).to eq('<a href="/?sort=column">label</a> ▾') end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sorting_helper-0.1.0 | spec/helpers/sorting_helper_spec.rb |