Sha256: 38b4b9c978cc122cd85528bab5c0d102bb5009e4a0fe72c5e867440cb07c9491
Contents?: true
Size: 1.85 KB
Versions: 3
Compression:
Stored size: 1.85 KB
Contents
require File.dirname(__FILE__) + '/../test_helper.rb' context "restful publish" do teardown do reset_config end specify "should result in a method .published?(:attr_key) return true for published attributes" do Pet.restful_publish(:person_id, :name) # person_id gets converted to a link automagically. Pet.restful_config.published?(:name).should.equal true Pet.restful_config.published?(:pets).should.equal false Pet.restful_config.published?(:species).should.equal false end specify "should have restful_options as an empty hash after calling restful_publish" do Person.restful_publish(:name, :pets => [:name, :species]) Person.restful_config.restful_options.should.==({}) end specify "should include attributes when publishe parameter is passed to to_restful" do Person.restful_publish(:name) Pet.restful_publish(:name) @person = Person.create @pet = @person.pets.create(:name => "Mietze") @pet.to_restful(:include => :owner).values.map(&:name).should.include :owner Pet.restful_config.whitelisted.should.not.include? :owner end end context "api publishing with nesting" do teardown do reset_config end specify "should result in a method .published?(:attr_key) return true for nested attributes" do Person.restful_publish(:name, :pets => [:name, :species]) Person.restful_config.published?(:pets).should.equal true end specify "should be invoke to_restful on the nested model with the specified nested attributes" do Person.restful_publish(:name, :pets => [:name, :species]) @person = Person.create(:name => "Joe Bloggs", :current_location => "Under a tree") @pet = @person.pets.create(:name => "Mietze", :species => "cat") Pet.any_instance.expects(:to_restful).with { |arg| arg.whitelisted == [:name, :species] } @person.to_restful end end
Version data entries
3 entries across 3 versions & 2 rubygems