the86-client 0.0.3 → 0.0.4
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 +11 -1
- data/lib/the86-client/version.rb +1 -1
- data/spec/posts_spec.rb +26 -0
- metadata +1 -1
data/lib/the86-client/post.rb
CHANGED
@@ -23,9 +23,19 @@ module The86::Client
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def hide(attributes = {})
|
26
|
+
set_hidden(true, attributes)
|
27
|
+
end
|
28
|
+
|
29
|
+
def unhide(attributes = {})
|
30
|
+
set_hidden(false, attributes)
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def set_hidden(hidden, attributes)
|
26
36
|
self.oauth_token = attributes[:oauth_token]
|
27
37
|
key = oauth_token ? :hidden_by_user : :hidden_by_site
|
28
|
-
patch(key =>
|
38
|
+
patch(key => hidden)
|
29
39
|
end
|
30
40
|
|
31
41
|
end
|
data/lib/the86-client/version.rb
CHANGED
data/spec/posts_spec.rb
CHANGED
@@ -80,6 +80,32 @@ module The86::Client
|
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
+
describe "#unhide" do
|
84
|
+
let(:post) { conversation.posts.build(id: 2) }
|
85
|
+
let(:url) { "https://example.org/api/v1/sites/test/conversations/32/posts/2" }
|
86
|
+
it "patches the post as hidden_by_site when no oauth_token" do
|
87
|
+
expect_request(
|
88
|
+
url: url.sub("https://", "https://user:pass@"),
|
89
|
+
method: :patch,
|
90
|
+
status: 200,
|
91
|
+
request_body: {hidden_by_site: false},
|
92
|
+
response_body: {id: 2, hidden_by_site: false},
|
93
|
+
)
|
94
|
+
post.unhide
|
95
|
+
end
|
96
|
+
it "patches the post as hidden_by_user when oauth_token present" do
|
97
|
+
expect_request(
|
98
|
+
url: url,
|
99
|
+
method: :patch,
|
100
|
+
status: 200,
|
101
|
+
request_body: {hidden_by_user: false},
|
102
|
+
request_headers: {"Authorization" => "Bearer secret"},
|
103
|
+
response_body: {id: 2, hidden_by_site: false},
|
104
|
+
)
|
105
|
+
post.unhide(oauth_token: "secret")
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
83
109
|
def original_post
|
84
110
|
Post.new(id: 64, conversation: conversation, content: "Hello!")
|
85
111
|
end
|