Sha256: 1ddea6860c1f92a613a01a100739dda3fe3048c6536f4115e9f77483156ef237
Contents?: true
Size: 1.61 KB
Versions: 3
Compression:
Stored size: 1.61 KB
Contents
require 'spec_helper' describe Vehicle do before { @vehicles = { :ford => Car.create( :manufacturer => 'Ford' ), :bmw => Car.create( :manufacturer => 'BMW' ), :daimler => Truck.create( :manufacturer => 'Daimler' ), :volvo => Truck.create( :manufacturer => 'Volvo' ), :kenworth => Truck.create( :manufacturer => 'Kenworth' ) } @vehicles.each { |name, vehicle| vehicle.reload vehicle.update_attribute :parking_order_position, 0 } @vehicles.each {|name, vehicle| vehicle.reload } } describe "ranking by STI parent" do before { @vehicles[:volvo].update_attribute :parking_order_position, :first @vehicles[:ford].update_attribute :parking_order_position, :first } describe "Vehicle" do subject { Vehicle.rank(:parking_order) } its(:size) { should == 5 } its(:first) { should == @vehicles[:ford] } its(:second) { should == @vehicles[:volvo] } end end describe "overriding parent's ranking" do describe "Vehicle" do it "should have one ranker object" do expect(Vehicle.rankers.count).to eq(1) end subject { Vehicle.rankers.first } its(:class_name) { should == 'Vehicle' } its(:column) { should == :parking_order } end describe "MotorBike" do it "should have one ranker object" do expect(MotorBike.rankers.count).to eq(1) end subject { MotorBike.rankers.first } its(:class_name) { should == 'Vehicle' } its(:column) { should == :parking_order } its(:with_same) { should == :color } end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ranked-model-0.4.4 | spec/sti-model/vehicle_spec.rb |
ranked-model-0.4.3 | spec/sti-model/vehicle_spec.rb |
ranked-model-0.4.2 | spec/sti-model/vehicle_spec.rb |