signatory 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -2,3 +2,4 @@
2
2
  pkg/*
3
3
  *.gem
4
4
  .bundle
5
+ *.swp
@@ -1,5 +1,19 @@
1
1
  module Signatory
2
2
  class Document < API::Base
3
+
4
+ def extend_expiration
5
+ connection.post(:extend_expiration)
6
+ end
7
+
8
+ def extend_expiration!
9
+ extend_expiration
10
+ reload
11
+ end
12
+
13
+ def expired?
14
+ Date.parse(expires_on) < Date.today
15
+ end
16
+
3
17
  private
4
18
  def self.instantiate_record(record, opts = {})
5
19
  record['recipients'] = [record['recipients']['recipient']].flatten unless record['recipients'].nil? || record['recipients'].is_a?(Array)
@@ -1,3 +1,3 @@
1
1
  module Signatory
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
@@ -32,4 +32,53 @@ describe Signatory::Document do
32
32
  doc.subject.should == 'Test number 2'
33
33
  end
34
34
  end
35
+
36
+ describe "#extend_expiration" do
37
+ before do
38
+ stub_request(:post, "https://rightsignature.com/api/documents/XXXXX/extend_expiration").
39
+ to_return(:body => "")
40
+ end
41
+
42
+ it "should post to the correct action" do
43
+ stub_document('XXXXX')
44
+ doc = Signatory::Document.find('XXXXX')
45
+ Signatory::Document.connection.should_receive(:post).with(:extend_expiration)
46
+ doc.extend_expiration
47
+ end
48
+ end
49
+
50
+ describe "#extend_expiration!" do
51
+ before :each do
52
+ stub_document('XXXXX')
53
+ @doc = Signatory::Document.find('XXXXX')
54
+ end
55
+
56
+ it "should extend the expiration date" do
57
+ @doc.stub!(:extend_expiration)
58
+ @doc.stub!(:reload)
59
+ @doc.should_receive(:extend_expiration)
60
+ @doc.extend_expiration!
61
+ end
62
+
63
+ it "should reload the document" do
64
+ @doc.stub!(:extend_expiration)
65
+ @doc.stub!(:reload)
66
+ @doc.should_receive(:reload)
67
+ @doc.extend_expiration!
68
+ end
69
+ end
70
+
71
+ describe "#expired?" do
72
+ it "should return true if the expires_on date is in the past" do
73
+ stub_document('XXXXX', :expires_on => 7.days.ago)
74
+ @doc = Signatory::Document.find('XXXXX')
75
+ @doc.expired?.should be_true
76
+ end
77
+
78
+ it "should return false if the expires_on date is in the future" do
79
+ stub_document('XXXXX', :expires_on => 7.days.from_now)
80
+ @doc = Signatory::Document.find('XXXXX')
81
+ @doc.expired?.should be_false
82
+ end
83
+ end
35
84
  end
@@ -47,5 +47,5 @@
47
47
  <processing-state>done-processing</processing-state>
48
48
  <original-url>https://originaldoc.doc</original-url>
49
49
  <content-type>package</content-type>
50
- <expires-on>2009-11-06T16:00:00-08:00</expires-on>
50
+ <expires-on><%= options[:expires_on] && options[:expires_on].iso8601 || '2009-11-06T16:00:00-08:00' %></expires-on>
51
51
  </document>
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 4
9
- version: 0.0.4
8
+ - 5
9
+ version: 0.0.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ryan Garver
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-10 00:00:00 -08:00
17
+ date: 2011-01-25 00:00:00 -08:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency