spec/model/paths_spec.rb in her-0.6.7 vs spec/model/paths_spec.rb in her-0.6.8

- old
+ new

@@ -123,9 +123,31 @@ expect { Foo::AdminUser.build_request_path(:id => "foo") }.to raise_error(Her::Errors::PathError, "Missing :_organization_id parameter to build the request path. Path is `organizations/:organization_id/users/:id`. Parameters are `{:id=>\"foo\"}`.") end end end + context "children model" do + before do + Her::API.setup :url => "https://api.example.com" do |builder| + builder.use Her::Middleware::FirstLevelParseJSON + builder.use Faraday::Request::UrlEncoded + builder.adapter :test do |stub| + stub.get("/users/foo") { |env| [200, {}, { :id => 'foo' }.to_json] } + end + end + + spawn_model("Foo::Model") { include_root_in_json true } + + class User < Foo::Model; end + @spawned_models << :User + end + + it "builds path using the children model name" do + User.find('foo').id.should == 'foo' + User.find('foo').id.should == 'foo' + end + end + context "nested model" do before do spawn_model "Foo::User" end