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.
@@ -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 => true)
38
+ patch(key => hidden)
29
39
  end
30
40
 
31
41
  end
@@ -1,5 +1,5 @@
1
1
  module The86
2
2
  module Client
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
@@ -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
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.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: