Sha256: 7bfd381f562fa805910241cbd2d0ab71d89091fe0a34f2d4ff73385a3266534a

Contents?: true

Size: 1.49 KB

Versions: 4

Compression:

Stored size: 1.49 KB

Contents

require File.dirname(__FILE__) + '/../test_helper.rb'

context "Configuration" do
  specify "should have an empty whitelist if only restful options are passed in" do
    config = Restful.cfg
    config.restful_options[:expansion] = :expanded
    config.whitelisted.should.empty
  end
  
  specify "should return fields without restful_options via whitelisted" do
    config = Restful.cfg([:one, :two])
    config.restful_options[:expansion] = :expanded
    config.whitelisted.should.not.include :restful_options
  end
  
  specify "should know if it has restful_options" do
    config = Restful.cfg([:one, :two])
    config.restful_options[:expansion] = :expanded
    config.restful_options.should.not.empty
  end
  
  specify "should be able to handle nested whitelist attributes" do
    config = Restful.cfg(:one, :two => [:a, :b])
    config.nested(:two).whitelisted.should.== [:a,:b]
  end
  
  specify "should know which attributes are published" do
    config = Restful.cfg(:one, :two => [:a, :b])
    config.published?(:two).should.== true
    config.published?(:one).should.== true
  end
  
  specify "should know if it is nested" do
    config = Restful.cfg(:one, :restful_options => {:nested => true})
    config.nested?.should.== true
  end
  
  specify "should preserve :include when :restful_options are present" do
    Person.restful_publish :pets
    p = Person.create
    p.pets.create
    
    restful = p.to_restful :include => :pets, :restful_options => {}
    restful.collections.size.should.== 1
  end
  
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
moviepilot-restful-0.2.18 test/rails/configuration_test.rb
moviepilot-restful-0.2.19 test/rails/configuration_test.rb
moviepilot-restful-0.2.20 test/rails/configuration_test.rb
restful-0.2.20 test/rails/configuration_test.rb