Sha256: cf9920825fcf621843178064f851dd4c7db76ececb7b2eeb4fbd3b407e301f33

Contents?: true

Size: 1.36 KB

Versions: 47

Compression:

Stored size: 1.36 KB

Contents

require File.dirname(__FILE__) + '/../../spec_helper'
require File.dirname(__FILE__) + '/../spec_helper_tables' unless metaclass.class_variable_defined? :@@set_up_demo_tables

require 'active_support'

describe "Sequel::Serializer with active support loaded" do

  describe "to_fos_json method" do
    before :each do 
      set_demo_db([TestTable,Dude,Horse])
    end

    it "adds :only=>[] to the options hash" do
      data = Trip.new
      mock(data).to_json({:only=>[], :methods=>[]})
      data.to_fos_json(:methods=>[])
    end

    it "handles single sequel model" do
      add_test_table_data({:id=>1, :'goofy name col' => 123})
      data = TestTable.first
      data.to_fos_json(:methods=>[:'goofy name col']).should == "{\"goofy name col\":123}"
    end

    it "handles an array of sequel models" do
      add_test_table_data({:id=>1, :'goofy name col' => 123})
      array = [TestTable.first]
      array.to_fos_json(:methods=>[:'goofy name col']).should=="[{\"goofy name col\":123}]"
      # another one just in case
      Dude.all.to_fos_json(:methods=>[:name]).should == "[{\"name\":\"dano\"},{\"name\":\"eric\"}]"
    end

    it "shows methods which are dynamically delegated" do
      add_test_table_data({:id=>1, :'date_col' => 123})
      data = TestTable.first
      data.to_fos_json(:methods=>[:date_col__round]).should == "{\"date_col__round\":123}"
    end
  end

end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
fossil-0.5.30 spec/sequel/serializer/json_serializer_with_active_support_spec.rb
fossil-0.5.29 spec/sequel/serializer/json_serializer_with_active_support_spec.rb
fossil-0.5.28 spec/sequel/serializer/json_serializer_with_active_support_spec.rb
fossil-0.5.27 spec/sequel/serializer/json_serializer_with_active_support_spec.rb
fossil-0.5.26 spec/sequel/serializer/json_serializer_with_active_support_spec.rb
fossil-0.5.25 spec/sequel/serializer/json_serializer_with_active_support_spec.rb
fossil-0.5.24 spec/sequel/serializer/json_serializer_with_active_support_spec.rb
fossil-0.5.23 spec/sequel/serializer/json_serializer_with_active_support_spec.rb
fossil-0.5.22 spec/sequel/serializer/json_serializer_with_active_support_spec.rb
fossil-0.5.21 spec/sequel/serializer/json_serializer_with_active_support_spec.rb
fossil-0.5.20 spec/sequel/serializer/json_serializer_with_active_support_spec.rb
fossil-0.5.19 spec/sequel/serializer/json_serializer_with_active_support_spec.rb
fossil-0.5.18 spec/sequel/serializer/json_serializer_with_active_support_spec.rb
fossil-0.5.17 spec/sequel/serializer/json_serializer_with_active_support_spec.rb
fossil-0.5.16 spec/sequel/serializer/json_serializer_with_active_support_spec.rb
fossil-0.5.15 spec/sequel/serializer/json_serializer_with_active_support_spec.rb
fossil-0.5.14 spec/sequel/serializer/json_serializer_with_active_support_spec.rb
fossil-0.5.13 spec/sequel/serializer/json_serializer_with_active_support_spec.rb
fossil-0.5.12 spec/sequel/serializer/json_serializer_with_active_support_spec.rb
fossil-0.5.11 spec/sequel/serializer/json_serializer_with_active_support_spec.rb