the86-client 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,5 +22,11 @@ module The86::Client
22
22
  )
23
23
  end
24
24
 
25
+ def hide(attributes = {})
26
+ self.oauth_token = attributes[:oauth_token]
27
+ key = oauth_token ? :hidden_by_user : :hidden_by_site
28
+ patch(key => true)
29
+ end
30
+
25
31
  end
26
32
  end
@@ -82,6 +82,14 @@ module The86
82
82
  self
83
83
  end
84
84
 
85
+ def patch(attributes)
86
+ self.attributes = connection.patch(
87
+ path: resource_path,
88
+ data: attributes,
89
+ status: 200
90
+ )
91
+ end
92
+
85
93
  def sendable_attributes
86
94
  attributes.reject do |key, value|
87
95
  [:id, :created_at, :updated_at].include?(key) ||
@@ -1,5 +1,5 @@
1
1
  module The86
2
2
  module Client
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -11,5 +11,15 @@ module The86::Client
11
11
  Post.new(in_reply_to_id: nil).reply?.must_equal false
12
12
  end
13
13
  end
14
+
15
+ describe "#user" do
16
+ let(:post) { Post.new(id: 1, user: {id: 2, name: "John Citizen"}) }
17
+ it "returns instance of The86::Client::User" do
18
+ post.user.must_be_instance_of(The86::Client::User)
19
+ end
20
+ it "contains the user details" do
21
+ post.user.name.must_equal "John Citizen"
22
+ end
23
+ end
14
24
  end
15
25
  end
@@ -54,13 +54,29 @@ module The86::Client
54
54
  end
55
55
  end
56
56
 
57
- describe "#user" do
58
- let(:post) { Post.new(id: 1, user: {id: 2, name: "John Citizen"}) }
59
- it "returns instance of The86::Client::User" do
60
- post.user.must_be_instance_of(The86::Client::User)
57
+ describe "#hide" do
58
+ let(:post) { conversation.posts.build(id: 2) }
59
+ let(:url) { "https://example.org/api/v1/sites/test/conversations/32/posts/2" }
60
+ it "patches the post as hidden_by_site when no oauth_token" do
61
+ expect_request(
62
+ url: url.sub("https://", "https://user:pass@"),
63
+ method: :patch,
64
+ status: 200,
65
+ request_body: {hidden_by_site: true},
66
+ response_body: {id: 2, hidden_by_site: true},
67
+ )
68
+ post.hide
61
69
  end
62
- it "contains the user details" do
63
- post.user.name.must_equal "John Citizen"
70
+ it "patches the post as hidden_by_user when oauth_token present" do
71
+ expect_request(
72
+ url: url,
73
+ method: :patch,
74
+ status: 200,
75
+ request_body: {hidden_by_user: true},
76
+ request_headers: {"Authorization" => "Bearer secret"},
77
+ response_body: {id: 2, hidden_by_site: true},
78
+ )
79
+ post.hide(oauth_token: "secret")
64
80
  end
65
81
  end
66
82
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: the86-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-30 00:00:00.000000000 Z
12
+ date: 2012-08-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday