<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,7 +1,21 @@
 = Agree2 Client
- 
+
+Agree2 (https://agree2.com) is a site for creating and maintaining contracts. 
+
+This Client library will let you integrate Agree2 into your own web applications to create full legal contracts between you and your users or between your users.
+
+== Getting Started
+
+First of all you need to signup with https://agree2.com. 
+
+Now go to the page http://agree2.dev/client_applications and register an application.
+
+Find the snippet of code on your client application page called &quot;Example using your own AccessToken&quot;. This provides you everything to get started creating agreements under you own account.
+
+
+
 Author::    Pelle Braendgaard (http://stakeventures.com)
-Copyright:: Copyright (c) 2008 Pelle Braendgaard
+Copyright:: Copyright (c) 2008 Extra Eagle LLC
 License::   MIT
 Git::       https://github.com/pelle/agree2-client/tree/master
 </diff>
      <filename>README.rdoc</filename>
    </modified>
    <modified>
      <diff>@@ -3,12 +3,27 @@ require 'rake'
 require 'rake/rdoctask'
 require 'rake/testtask'
 require 'spec/rake/spectask'
-
+require 'rake/gempackagetask'
+require 'yaml'
 namespace :rdoc do |ns|
   Rake::RDocTask.new(:doc) do |rd|
     rd.main = &quot;README.rdoc&quot;
+    rd.rdoc_dir = 'doc'
     rd.rdoc_files.include(&quot;README.rdoc&quot;, &quot;lib/**/*.rb&quot;)
+    rd.options &lt;&lt; &quot;-t Agree2&quot;
+  end
+
+  desc 'Publish RDoc to RubyForge.'
+  task :publish_docs =&gt; [:doc] do
+    config = YAML.load(File.read(File.expand_path(&quot;~/.rubyforge/user-config.yml&quot;)))
+    host = &quot;#{config[&quot;username&quot;]}@rubyforge.org&quot;
+
+    remote_dir = &quot;/var/www/gforge-projects/agree2&quot;
+    local_dir = 'doc'
+
+    sh %{rsync -av --delete #{local_dir}/ #{host}:#{remote_dir}}
   end
+  
 end
 
 namespace :spec do |ns|
@@ -25,4 +40,58 @@ namespace :spec do |ns|
   end
 end
 
+namespace :gem do |gem|
+  File.open( 'agree2.gemspec') do |f|
+    @gem=eval(f.read)
+    @version=@gem.version.to_s
+  end
+  
+  Rake::GemPackageTask.new @gem do |pkg|
+    pkg.need_tar = true
+    pkg.need_zip = true
+  end
+
+  desc 'Install the package as a gem.'
+  task :install =&gt; [:clean, :package] do
+    gem = Dir['pkg/*.gem'].first
+    sh &quot;sudo gem install --local #{gem}&quot;
+  end
+
+  
+  desc 'Package and upload the release to rubyforge.'
+  task :release =&gt; [:clean, :package] do |t|
+    pkg = &quot;pkg/#{name}-#{@version}&quot;
+
+    if $DEBUG then
+      puts &quot;release_id = rf.add_release #{rubyforge_name.inspect}, #{name.inspect}, #{@version.inspect}, \&quot;#{pkg}.tgz\&quot;&quot;
+      puts &quot;rf.add_file #{rubyforge_name.inspect}, #{name.inspect}, release_id, \&quot;#{pkg}.gem\&quot;&quot;
+    end
+
+    rf = RubyForge.new.configure
+    puts &quot;Logging in&quot;
+    rf.login
+
+#    c = rf.userconfig
+#    c[&quot;release_notes&quot;] = description if description
+#    c[&quot;release_changes&quot;] = changes if changes
+#    c[&quot;preformatted&quot;] = true
+
+    files = [&quot;#{pkg}.tgz&quot;,
+             &quot;#{pkg}.zip&quot;,
+             &quot;#{pkg}.gem&quot;].compact
+
+    puts &quot;Releasing #{name} v. #{@version}&quot;
+    rf.add_release rubyforge_name, name, @version, *files
+  end
+  
+end
+
+desc &quot;Clean up all dirt&quot;
+task :clean =&gt; [ &quot;rdoc:clobber_doc&quot;, &quot;gem:clobber_package&quot; ] do
+   %w(diff diff.txt email.txt ri *.gem *~ **/*~ *.rbc **/*.rbc coverage).each do |pattern|
+    files = Dir[pattern]
+    rm_rf files, :verbose =&gt; true unless files.empty?
+  end
+end
+
 task :default=&gt;[:spec]</diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -13,8 +13,59 @@ module Agree2
       @parties=Agree2::ProxyCollection.new self,&quot;#{self.path}/parties&quot;,'Party',values
     end
 
-    def to_param
+    def to_param #:nodoc:
       permalink
     end
+    
+    def respond_to?(symbol, include_priv = false)  #:nodoc:
+      return true if super symbol,include_priv
+      return false if fields.nil?||fields.empty?
+      method=symbol.to_s
+      if method=~/(.+)=$/
+        field=$1
+        setter=true
+      else
+        field=method
+        setter=false
+      end
+      fields.has_key?(field)
+    end
+    
+    # Finalize marks a draft agreement as being ready to accept
+    def finalize!
+      user.post(path+&quot;/finalize&quot;)==&quot; &quot;
+    end
+    
+    protected
+    
+    def attributes_for_save #:nodoc:
+      if new_record?
+        {self.class.singular_name=&gt;attributes}
+      else
+        {&quot;fields&quot;=&gt;fields}
+      end
+    end
+    
+    def method_missing(method, *args, &amp;block)  #:nodoc:
+      return super(method, *args, &amp;block) if fields.nil?||fields.empty?
+      method=method.to_s
+      if method=~/(.+)=$/
+        field=$1
+        setter=true
+      else
+        field=method
+        setter=false
+      end
+      if fields.has_key?(field)
+        if setter
+          fields[field]=args.first
+        else
+          fields[field]
+        end
+      else
+        super method, *args, &amp;block
+      end
+    end
+    
   end
 end
\ No newline at end of file</diff>
      <filename>lib/agree2/agreement.rb</filename>
    </modified>
    <modified>
      <diff>@@ -18,28 +18,35 @@ module Agree2
         read_inheritable_attribute(&quot;serializable_attributes&quot;)
       end
       
-      def instance_url(id) #:nodoc:
-        &quot;/#{collection_name}/#{id}&quot;
+      def collection_path #:nodoc:
+        &quot;/#{collection_name}&quot;
+      end
+
+      def instance_path(id) #:nodoc:
+        &quot;#{collection_path}/#{id}&quot;
       end
 
       def collection_name #:nodoc:
         self.to_s.demodulize.tableize
       end
+
+      def singular_name #:nodoc:
+        self.to_s.demodulize.underscore.singularize
+      end
       
       # Gets an instance of a resource
       def get(container,id)
         user=(container.is_a?(User) ? container : container.user)
-        new( container, user.get(container.path+instance_url(id)+&quot;.json&quot;))
+        new( container, user.get(container.path+instance_path(id)+&quot;.json&quot;))
       end
       
     end
 
-    attr_accessor :user,:attributes,:container
+    attr_accessor :user,:container
         
     def initialize(container,fields={})#:nodoc:
       @container=container
       @user=(container.is_a?(User) ? container : container.user)
-      attributes={}
       if fields.is_a?(Hash)
         load_attributes(fields)
       else
@@ -47,9 +54,19 @@ module Agree2
       end
     end
     
+    # Has this record been saved to the server yet?
+    def new_record?
+      @from_wire!=true
+    end
+    
     # Reloads the object from Agree2's servers
     def reload
-      load_json(user.get(path+&quot;.json&quot;))
+      load_json(user.get(path))
+    end
+
+    # Destroys the object from Agree2's servers
+    def destroy
+      user.delete(path)
     end
     
     # Returns the full URL for the object
@@ -59,7 +76,7 @@ module Agree2
     
     # Returns the relative path to the object
     def path #:nodoc:
-      self.container.path+self.class.instance_url(to_param)
+      self.container.path+self.class.instance_path(to_param)
     end
     
     # The primary key of the object
@@ -67,8 +84,30 @@ module Agree2
       id
     end
     
+    # Saves the record to the server
+    def save
+      if new_record?
+        load_json(@user.post(&quot;#{self.container.path}/#{self.class.collection_name}&quot;,attributes_for_save))
+      else
+        load_json(@user.put(&quot;#{path}&quot;,attributes_for_save))
+      end
+    end
+    
+    # Get the primary attributes of an object as a hash
+    def attributes
+      self.class.serializable_attributes.inject({}) do |h,field|
+        value=self.send(field)
+        h[field]=value if value
+        h
+      end
+    end
+    
     protected
     
+    def attributes_for_save #:nodoc:
+      {self.class.singular_name=&gt;attributes}
+    end
+    
     def decode(element) #:nodoc:
         for field in self.class.serializable_attributes
           method_name=&quot;#{field.to_s}=&quot;.to_sym
@@ -78,6 +117,7 @@ module Agree2
     end
 
     def load_attributes(attributes) #:nodoc:
+      @attributes=attributes
       attributes.each_pair do |key,value|
         method_name=&quot;#{key.to_s}=&quot;.to_sym
         self.send(method_name,value) if self.respond_to?(method_name)
@@ -85,6 +125,7 @@ module Agree2
     end
         
     def load_json(json) #:nodoc:
+      @from_wire=true
       load_attributes(JSON.parse(json))
     end
 #    private</diff>
      <filename>lib/agree2/base.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,6 +3,8 @@ module Agree2
     attr_serializable :id,:role,:email,:first_name,:last_name,:created_at,:updated_at,:organization_name
     alias_method :agreement,:container  
     
+    # Creates a one time signed url to redirect your user to their acceptance page. This url is only valid once. Call again to
+    # redirect your user to the agreement again.
     def present
       path=&quot;/present/#{agreement.permalink}/to/#{email}&quot;
       AGREE2_URL+user.client.consumer.create_signed_request(:get,path,user.access_token,{:scheme=&gt;:query_string}).path</diff>
      <filename>lib/agree2/party.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
 require 'json'
 module Agree2
   class ProxyCollection
-    alias_method :proxy_respond_to?, :respond_to?
+    alias_method :proxy_respond_to?, :respond_to? #:nodoc:
     instance_methods.each { |m| undef_method m unless m =~ /(^__|^nil\?$|^send$|proxy_)/ }
     attr_accessor :user,:path,:singular
     def initialize(container,path,class_name=nil,values=nil)
@@ -18,44 +18,55 @@ module Agree2
       end
     end
     
+    # Builds an instance of the record
+    def build(attributes={})
+      @klass.new @container,attributes
+    end
+    
+    # Builds and saves and instance of the record
+    def create(attributes={})
+      build(attributes).save
+    end
+    
+    # Finds the instance given the id
     def find(id)
       @klass.get @container,id
     end
     
-    def respond_to?(symbol, include_priv = false)
+    def respond_to?(symbol, include_priv = false) #:nodoc:
       proxy_respond_to?(symbol, include_priv) || (load_target &amp;&amp; @target.respond_to?(symbol, include_priv))
     end
     
     # Explicitly proxy === because the instance method removal above
     # doesn't catch it.
-    def ===(other)
+    def ===(other) #:nodoc:
       load_target
       other === @target
     end
     
     protected
     
-    def parse_json(json)
+    def parse_json(json) #:nodoc:
       instantiate_items(JSON.parse(json))
     end
     
-    def instantiate_items(list=[])
+    def instantiate_items(list=[]) #:nodoc:
       list.collect{|e|instantiate_item(e)}
     end
     
-    def instantiate_item(attributes={})
+    def instantiate_item(attributes={}) #:nodoc:
       @klass.new @container,attributes
     end
         
-    def load_target
-      @target||=parse_json(@user.get(&quot;#{self.path}.json&quot;))
+    def load_target #:nodoc:
+      @target||=parse_json(@user.get(&quot;#{self.path}&quot;))
     end
     
-    def reset
+    def reset #:nodoc:
       @target=nil
     end
     
-    def method_missing(method, *args, &amp;block)
+    def method_missing(method, *args, &amp;block) #:nodoc:
       if load_target
         @target.send(method, *args, &amp;block)
       end</diff>
      <filename>lib/agree2/proxy_collection.rb</filename>
    </modified>
    <modified>
      <diff>@@ -94,7 +94,7 @@ module Agree2
     protected
 
     def raw_prepare(params={}) #:nodoc:
-      user.post(&quot;/masters/#{permalink}/prepare&quot;,params)
+      Agreement.new @user, user.post(&quot;/masters/#{permalink}/prepare&quot;,params)
     end
   end
 end
\ No newline at end of file</diff>
      <filename>lib/agree2/template.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
+AGREE2_JSON_HEADERS={'Content-Type'=&gt;'application/json','Accept'=&gt;'application/json'}
 module Agree2
   class User
     attr_accessor :client,:access_token
-    
     def initialize(client,key,secret)
       @client=client
       @access_token=OAuth::AccessToken.new @client.consumer,key,secret
@@ -16,23 +16,23 @@ module Agree2
     end
     
     def get(path)
-      handle_response @access_token.get(path)
+      handle_response @access_token.get(path,AGREE2_JSON_HEADERS)
     end
 
     def head(path)
-      handle_response @access_token.head(path)
+      handle_response @access_token.head(path,AGREE2_JSON_HEADERS)
     end
     
     def post(path,data=nil)
-      handle_response @access_token.post(path,(data ? data.to_json : nil),{'Content-Type'=&gt;'application/json'})
+      handle_response @access_token.post(path,(data ? data.to_json : nil),AGREE2_JSON_HEADERS)
     end
     
     def put(path,data=nil)
-      handle_response @access_token.put(path,(data ? data.to_json : nil),{'Content-Type'=&gt;'application/json'})
+      handle_response @access_token.put(path,(data ? data.to_json : nil),AGREE2_JSON_HEADERS )
     end
     
     def delete(path)
-      handle_response @access_token.delete(path)
+      handle_response @access_token.delete(path,AGREE2_JSON_HEADERS)
     end
 
     # OAuth Stuff below here
@@ -56,6 +56,8 @@ module Agree2
       case response.code
       when &quot;200&quot;
         response.body
+      when &quot;201&quot;
+        response.body
       when &quot;302&quot;
         if response['Location']=~/(#{AGREE2_URL})\/(.*)$/
           parts=$2.split('/')</diff>
      <filename>lib/agree2/user.rb</filename>
    </modified>
    <modified>
      <diff>@@ -10,7 +10,11 @@ describe Agree2::Agreement do
     before(:each) do
       @agreement=Agree2::Agreement.new(@user,{:title=&gt;&quot;My Title&quot;,:body=&gt;&quot;My Body&quot;})
     end
-  
+    
+    it &quot;should have attribute hash&quot; do
+      @agreement.attributes.should=={:title=&gt;&quot;My Title&quot;,:body=&gt;&quot;My Body&quot;}
+    end
+    
     it &quot;should have a user&quot; do
       @agreement.user.should==@user
     end
@@ -23,9 +27,32 @@ describe Agree2::Agreement do
       @agreement.body.should==&quot;My Body&quot;
     end
     
+    it &quot;should be new record&quot; do
+      @agreement.should be_new_record
+    end
+    
+    describe &quot;Save to Server&quot; do
+      before(:each) do
+        @user.should_receive(:post).with(&quot;/agreements&quot;,{'agreement'=&gt;{:title=&gt;&quot;My Title&quot;,:body=&gt;&quot;My Body&quot;}}).and_return(@json)
+      end
+      
+      it &quot;should save and return true&quot; do
+        @agreement.save
+      end
+
+      it &quot;should no longer be new record&quot; do
+        @agreement.save
+        @agreement.should_not be_new_record
+      end
+
+      it &quot;should have a permalink&quot; do
+        @agreement.save
+        @agreement.permalink.should_not be_nil
+      end
+    end
   end
 
-  describe &quot;from xml&quot; do
+  describe &quot;from json&quot; do
 
     before(:each) do
       @agreement=Agree2::Agreement.new(@user,@json)
@@ -67,8 +94,66 @@ describe Agree2::Agreement do
         &quot;amount&quot;=&gt; &quot;100&quot;,
         &quot;currency&quot;=&gt; &quot;USD&quot;
       }
-    end    
+    end
+    
+    it &quot;should have methods defined for fields&quot; do
+      @agreement.amount.should==&quot;100&quot;
+      @agreement.currency.should==&quot;USD&quot;
+    end
+    [:amount,:currency].each do |field|
+      it &quot;should support setting the value&quot; do
+        @agreement.send(&quot;#{field.to_s}=&quot;.to_sym,&quot;test this&quot;)
+        @agreement.send(field).should==&quot;test this&quot;
+        @agreement.fields[field.to_s].should==&quot;test this&quot;
+      end
+      
+      it &quot;should have respond_to wired for field accessor&quot; do
+        @agreement.respond_to?(field).should==true
+      end
+      
+      it &quot;should have respond_to wired for field setter&quot; do
+        @agreement.respond_to?(&quot;#{field.to_s}=&quot;.to_sym).should==true
+      end
+    end
+    
+    it &quot;should not be new record&quot; do
+      @agreement.should_not be_new_record
+    end
     
+    it &quot;should reload&quot; do
+      @user.should_receive(:get).with(&quot;/agreements/hello&quot;).and_return(@json)
+      @agreement.reload
+    end
+
+    it &quot;should destroy&quot; do
+      @user.should_receive(:delete).with(&quot;/agreements/hello&quot;).and_return(&quot;&quot;)
+      @agreement.destroy
+    end
+    
+    it &quot;should finalize&quot; do
+      @user.should_receive(:post).with(&quot;/agreements/hello/finalize&quot;).and_return(&quot; &quot;)
+      @agreement.finalize!.should==true
+    end
+    
+    describe &quot;Save to Server&quot; do
+      before(:each) do
+        @user.should_receive(:put).with(&quot;/agreements/hello&quot;,{&quot;fields&quot;=&gt;@agreement.fields}).and_return(@json)
+      end
+      
+      it &quot;should save and return true&quot; do
+        @agreement.save
+      end
+
+      it &quot;should not a be new record&quot; do
+        @agreement.save
+        @agreement.should_not be_new_record
+      end
+
+      it &quot;should have a permalink&quot; do
+        @agreement.save
+        @agreement.permalink.should_not be_nil
+      end
+    end
   end
 
   describe &quot;load from server&quot; do
@@ -94,7 +179,12 @@ describe Agree2::Agreement do
       do_get
       @agreement.permalink.should==&quot;hello&quot;
     end
-
+    
+    it &quot;should not be new record&quot; do
+      do_get
+      @agreement.should_not be_new_record
+    end
+    
   end
 end
 </diff>
      <filename>spec/agreement_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,7 +9,6 @@
   &quot;agreement_id&quot;: 757,
   &quot;user_id&quot;: null,
   &quot;first_name&quot;: &quot;Bob&quot;,
-  &quot;accept_code&quot;: &quot;d373b3dc17b7177aa0626e6ce7f449fcc3ca7c9c&quot;,
   &quot;last_name&quot;: &quot;Wildcat&quot;,
   &quot;email&quot;: &quot;bob@gmail.inv&quot;,
   &quot;created_at&quot;: &quot;2008/08/12 22:04:51 +0000&quot;</diff>
      <filename>spec/fixtures/party.json</filename>
    </modified>
    <modified>
      <diff>@@ -11,13 +11,17 @@ describe Party do
     @client=Agree2::Client.new &quot;client_key&quot;,&quot;client_secret&quot;
     @user=Agree2::User.new(@client,&quot;token&quot;,&quot;token_secret&quot;)
     @agreement=Agreement.new @user,{:permalink=&gt;'hello'}
+    @json=IO.read(File.join(File.dirname(__FILE__),&quot;fixtures&quot;,&quot;party.json&quot;))
   end
   
-  describe &quot;Built from hash&quot; do
+  describe &quot;Create new&quot; do
     before(:each) do
-      @party=Party.new(@agreement,{:first_name=&gt;&quot;Bob&quot;,:last_name=&gt;&quot;Wildcat&quot;,:email=&gt;'bob@gmail.inv',:id=&gt;1102})
+      @party=Party.new(@agreement,{:first_name=&gt;&quot;Bob&quot;,:last_name=&gt;&quot;Wildcat&quot;,:email=&gt;'bob@gmail.inv'})
     end
-  
+    it &quot;should be new record&quot; do
+      @party.should be_new_record
+    end
+    
     it &quot;should have agreement&quot; do
       @party.agreement.should==@agreement
     end
@@ -34,32 +38,32 @@ describe Party do
       @party.last_name.should==&quot;Wildcat&quot;
     end
     
-    it &quot;should have a path&quot; do
-      @party.path.should==&quot;/agreements/hello/parties/1102&quot;
-    end
-    
-    it &quot;should have a url&quot; do
-      @party.to_url.should==&quot;https://agree2.com/agreements/hello/parties/1102&quot;
-    end
-    
-    it &quot;should generate present url&quot; do
-      present_url=@party.present
-      present_url=~/^(http.*)\?(.*)$/
-      $1.should==&quot;https://agree2.com/present/hello/to/bob@gmail.inv&quot;
-    end
-    
-    it &quot;should verify present url&quot; do
-      present_url=@party.present
-      request = Rack::Request.new(Rack::MockRequest.env_for(present_url))
-      OAuth::Signature.verify(request,{:consumer=&gt;@client.consumer,:token=&gt;@user.access_token}).should==true
+    describe &quot;Save to Server&quot; do
+      before(:each) do      
+        @user.should_receive(:post).with(&quot;/agreements/hello/parties&quot;,
+          {'party'=&gt;{:first_name=&gt;&quot;Bob&quot;,:last_name=&gt;&quot;Wildcat&quot;,:email=&gt;'bob@gmail.inv'}}).and_return(@json)
+      end
       
+      it &quot;should save and return true&quot; do
+        @party.save
+      end
+
+      it &quot;should no longer be new record&quot; do
+        @party.save
+        @party.should_not be_new_record
+      end
+
+      it &quot;should have a permalink&quot; do
+        @party.save
+        @party.id.should==1102
+      end
     end
+    
   end
 
   describe &quot;from json&quot; do
 
     before(:each) do
-      @json=IO.read(File.join(File.dirname(__FILE__),&quot;fixtures&quot;,&quot;party.json&quot;))
       @party=Party.new(@agreement,@json)
     end
 
@@ -87,6 +91,31 @@ describe Party do
       @party.to_url.should==&quot;https://agree2.com/agreements/hello/parties/1102&quot;
     end
     
+    it &quot;should generate present url&quot; do
+      present_url=@party.present
+      present_url=~/^(http.*)\?(.*)$/
+      $1.should==&quot;https://agree2.com/present/hello/to/bob@gmail.inv&quot;
+    end
+    
+    it &quot;should verify present url&quot; do
+      present_url=@party.present
+      request = Rack::Request.new(Rack::MockRequest.env_for(present_url))
+      OAuth::Signature.verify(request,{:consumer=&gt;@client.consumer,:token=&gt;@user.access_token}).should==true
+      
+    end
+    
+    describe &quot;Save to Server&quot; do
+      before(:each) do      
+        @user.should_receive(:put).with(&quot;/agreements/hello/parties/1102&quot;,
+          {'party'=&gt;@party.attributes}).and_return(@json)
+      end
+      
+      it &quot;should save and return true&quot; do
+        @party.save
+      end
+
+    end
+    
   end
 end
 </diff>
      <filename>spec/party_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -62,6 +62,19 @@ describe Agree2::ProxyCollection do
                       IO.read(File.join(File.dirname(__FILE__),&quot;fixtures&quot;,&quot;agreement.json&quot;)))
       @agreements.find('something')
     end
+    
+    it &quot;should instantiate a new party&quot; do
+      Agree2::Agreement.should_receive(:new).with(@user,{:title=&gt;&quot;Test&quot;,:body=&gt;&quot;Body&quot;})
+      @agreements.build :title=&gt;&quot;Test&quot;,:body=&gt;&quot;Body&quot;
+    end
+    
+    it &quot;should create and save a new party&quot; do
+      @agreement=mock(&quot;agreement&quot;)
+      Agree2::Agreement.should_receive(:new).with(@user,{:title=&gt;&quot;Test&quot;,:body=&gt;&quot;Body&quot;}).and_return(@agreement)
+      @agreement.should_receive(:save)
+      @agreements.create :title=&gt;&quot;Test&quot;,:body=&gt;&quot;Body&quot;
+    end
+    
   end
   
   describe &quot;nested load&quot; do
@@ -94,6 +107,18 @@ describe Agree2::ProxyCollection do
                       IO.read(File.join(File.dirname(__FILE__),&quot;fixtures&quot;,&quot;party.json&quot;)))
       @parties.find(123)
     end
+
+    it &quot;should instantiate a new party&quot; do
+      Agree2::Party.should_receive(:new).with(@agreement,{:first_name=&gt;&quot;Bob&quot;,:last_name=&gt;&quot;Galbraith&quot;,:email=&gt;'bob@bob.inv'})
+      @parties.build :first_name=&gt;&quot;Bob&quot;,:last_name=&gt;&quot;Galbraith&quot;,:email=&gt;'bob@bob.inv'
+    end
+    
+    it &quot;should create and save a new party&quot; do
+      @party=mock(&quot;party&quot;)
+      Agree2::Party.should_receive(:new).with(@agreement,{:first_name=&gt;&quot;Bob&quot;,:last_name=&gt;&quot;Galbraith&quot;,:email=&gt;'bob@bob.inv'}).and_return(@party)
+      @party.should_receive(:save)
+      @parties.create :first_name=&gt;&quot;Bob&quot;,:last_name=&gt;&quot;Galbraith&quot;,:email=&gt;'bob@bob.inv'
+    end    
     
   end
 end
\ No newline at end of file</diff>
      <filename>spec/proxy_collection_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,6 +7,8 @@ describe Agree2::Template do
     @template=Agree2::Template.new(@user,{:permalink=&gt;'hello'})
     @fields={:amount=&gt;100}
     @bob={:first_name=&gt;'Bob',:last_name=&gt;'Green',:email=&gt;'bob@green.inv'}
+    @json=IO.read(File.join(File.dirname(__FILE__),&quot;fixtures&quot;,&quot;agreement.json&quot;))
+    
   end
 
   it &quot;should have a user&quot; do
@@ -38,7 +40,7 @@ describe Agree2::Template do
     end
 
     it &quot;should call raw_prepare with correct parameters&quot; do
-      @user.should_receive(:post).with(&quot;/masters/hello/prepare&quot;,:fields=&gt;@fields,:parties=&gt;{:client=&gt;@bob})
+      @user.should_receive(:post).with(&quot;/masters/hello/prepare&quot;,:fields=&gt;@fields,:parties=&gt;{:client=&gt;@bob}).and_return(@json)
       @template.prepare(@fields,{:client=&gt;@bob})
     end
 
@@ -68,7 +70,7 @@ describe Agree2::Template do
 
     it &quot;should call raw_prepare with correct parameters&quot; do
       @user.should_receive(:post).with(&quot;/masters/hello/prepare&quot;,:fields=&gt;@fields,
-                :parties=&gt;{:client=&gt;@bob,'application'=&gt;:application},:sign=&gt;'application')
+                :parties=&gt;{:client=&gt;@bob,'application'=&gt;:application},:sign=&gt;'application').and_return(@json)
       @template.prepare_and_sign(@fields,{:client=&gt;@bob})
     end
 </diff>
      <filename>spec/template_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -41,19 +41,19 @@ describe Agree2::User do
     
     [:get,:head,:delete].each do |m|
       it &quot;should perform http #{m.to_s}&quot; do
-        @token.should_receive(m).with(&quot;/test&quot;).and_return(@response)
+        @token.should_receive(m).with(&quot;/test&quot;,{'Content-Type'=&gt;'application/json','Accept'=&gt;'application/json'}).and_return(@response)
         @user.send(m,&quot;/test&quot;).should==@json
       end
     end
 
     [:post,:put].each do |m|
       it &quot;should perform http #{m.to_s} with no data&quot; do
-        @token.should_receive(m).with(&quot;/test&quot;,nil,{'Content-Type'=&gt;'application/json'}).and_return(@response)
+        @token.should_receive(m).with(&quot;/test&quot;,nil,{'Content-Type'=&gt;'application/json','Accept'=&gt;'application/json'}).and_return(@response)
         @user.send(m,&quot;/test&quot;).should==@json
       end
 
       it &quot;should perform http #{m.to_s} with hash&quot; do
-        @token.should_receive(m).with(&quot;/test&quot;,'{&quot;test&quot;:&quot;this&quot;}',{'Content-Type'=&gt;'application/json'}).and_return(@response)
+        @token.should_receive(m).with(&quot;/test&quot;,'{&quot;test&quot;:&quot;this&quot;}',{'Content-Type'=&gt;'application/json','Accept'=&gt;'application/json'}).and_return(@response)
         @user.send(m,&quot;/test&quot;,{:test=&gt;'this'}).should==@json
       end
     end</diff>
      <filename>spec/user_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>ab2e56650e5163339c076a5d9e615e19a3714179</id>
    </parent>
  </parents>
  <author>
    <name>Pelle Braendgaard</name>
    <email>pelleb@gmail.com</email>
  </author>
  <url>http://github.com/pelle/agree2-client/commit/ac2ba29a5c8037f59c6951b05c42cfa09a00f684</url>
  <id>ac2ba29a5c8037f59c6951b05c42cfa09a00f684</id>
  <committed-date>2008-08-25T02:48:42-07:00</committed-date>
  <authored-date>2008-08-25T02:48:42-07:00</authored-date>
  <message>Improved build structure.
Full crud support for individual objects as well as proxy collections</message>
  <tree>84fd799c18098c90282e234ce2865b975c6c3d29</tree>
  <committer>
    <name>Pelle Braendgaard</name>
    <email>pelleb@gmail.com</email>
  </committer>
</commit>
