spec/requests/main_spec.rb in merb-admin-0.4.3 vs spec/requests/main_spec.rb in merb-admin-0.4.4
- old
+ new
@@ -87,9 +87,41 @@
it "should contain \"Select model to edit\"" do
@response.body.should contain("Select player to edit")
end
end
+ describe "list with sort" do
+ before(:each) do
+ MerbAdmin::AbstractModel.new("Player").create(:team_id => rand(99999), :number => 42, :name => "Jackie Robinson", :sex => :male, :position => :second)
+ MerbAdmin::AbstractModel.new("Player").create(:team_id => rand(99999), :number => 32, :name => "Sandy Koufax", :sex => :male, :position => :pitcher)
+ @response = request(url(:admin_list, :model_name => "player"), :params => {:sort => "name"})
+ end
+
+ it "should respond sucessfully" do
+ @response.should be_successful
+ end
+
+ it "should be sorted correctly" do
+ @response.body.should contain(/Jackie Robinson.*Sandy Koufax/m)
+ end
+ end
+
+ describe "list with reverse sort" do
+ before(:each) do
+ MerbAdmin::AbstractModel.new("Player").create(:team_id => rand(99999), :number => 42, :name => "Jackie Robinson", :sex => :male, :position => :second)
+ MerbAdmin::AbstractModel.new("Player").create(:team_id => rand(99999), :number => 32, :name => "Sandy Koufax", :sex => :male, :position => :pitcher)
+ @response = request(url(:admin_list, :model_name => "player"), :params => {:sort => "name", :sort_reverse => "true"})
+ end
+
+ it "should respond sucessfully" do
+ @response.should be_successful
+ end
+
+ it "should be sorted correctly" do
+ @response.body.should contain(/Sandy Koufax.*Jackie Robinson/m)
+ end
+ end
+
describe "list with 2 objects", :given => "two players exist" do
before(:each) do
MerbAdmin[:paginate] = true
MerbAdmin[:per_page] = 1
@response = request(url(:admin_list, :model_name => "player"))