Sha256: fb06e1e6bc3b13743070b1eba57e48b8a971f6829f05436e51c99ead5fca3682
Contents?: true
Size: 1.86 KB
Versions: 2
Compression:
Stored size: 1.86 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.include?(:owner).should.equal false 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
purzelrakete-restful-0.2.10 | test/rails/restful_publish_test.rb |
purzelrakete-restful-0.2.9 | test/rails/restful_publish_test.rb |