Sha256: e67f412fd4a5936dcb2005114c15f0df34533322d02a7218eb0d08e8bdfe2161
Contents?: true
Size: 1.73 KB
Versions: 6
Compression:
Stored size: 1.73 KB
Contents
require "spec_helper" require "scoped_search/rails_helper" module ActionViewHelperStubs def html_escape(str) str end def tag_options(options) "" end end describe ScopedSearch::RailsHelper do include ScopedSearch::RailsHelper include ActionViewHelperStubs let(:params) { HashWithIndifferentAccess.new(:controller => "resources", :action => "search") } it "should generate a link with the order param set" do should_receive(:url_for).with( "controller" => "resources", "action" => "search", "order" => "field ASC" ).and_return("/example") sort("field") end it "should generate a link with order param set to alternative default sorting order" do should_receive(:url_for).with( "controller" => "resources", "action" => "search", "order" => "field DESC" ).and_return("/example") sort("field", :default => "DESC") end it "should generate a link with the order param inverted" do should_receive(:url_for).with( "controller" => "resources", "action" => "search", "order" => "field DESC" ).and_return("/example") params[:order] = "field ASC" sort("field") end it "should generate a link with other parameters retained" do should_receive(:url_for).with( "controller" => "resources", "action" => "search", "walrus" => "unicorns", "order" => "field ASC" ).and_return("/example") params[:walrus] = "unicorns" sort("field") end it "should replace the current sorting order" do should_receive(:url_for).with( "controller" => "resources", "action" => "search", "order" => "other ASC" ).and_return("/example") params[:order] = "field ASC" sort("other") end end
Version data entries
6 entries across 6 versions & 1 rubygems