the86-client 0.0.2 → 0.0.3
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/lib/the86-client/post.rb +6 -0
- data/lib/the86-client/resource.rb +8 -0
- data/lib/the86-client/version.rb +1 -1
- data/spec/post_spec.rb +10 -0
- data/spec/posts_spec.rb +22 -6
- metadata +2 -2
data/lib/the86-client/post.rb
CHANGED
@@ -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) ||
|
data/lib/the86-client/version.rb
CHANGED
data/spec/post_spec.rb
CHANGED
@@ -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
|
data/spec/posts_spec.rb
CHANGED
@@ -54,13 +54,29 @@ module The86::Client
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
describe "#
|
58
|
-
let(:post) {
|
59
|
-
|
60
|
-
|
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 "
|
63
|
-
|
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.
|
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-
|
12
|
+
date: 2012-08-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|