storify 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/storify.rb +1 -0
- data/lib/storify/client.rb +17 -2
- data/spec/client_spec.rb +43 -3
- data/spec/storify_spec.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58748b03027c0d1b55dab4d3c625a623f5ac885b
|
4
|
+
data.tar.gz: 35b8e4dfdf2ffbea53947b09dbb0bb64bcf6700e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a599dff3581d8912472d1f096abde3c38867437828f7fbba68e780aa42087e565bb627b9c96e8b992d2737d5735f500f8c8ca7657d40566d6eb10a09e66d3d0
|
7
|
+
data.tar.gz: 8337f44f6dabe2e3d3bb8d7c95b5c7b1d55b31467a8740933684047ceb93c04dbb37abddb7b18c017cf3ea1803e8a6088aae63b8241eab642a7fc39debf00feb
|
data/lib/storify.rb
CHANGED
data/lib/storify/client.rb
CHANGED
@@ -135,8 +135,23 @@ module Storify
|
|
135
135
|
User.new.extend(UserRepresentable).from_json(json)
|
136
136
|
end
|
137
137
|
|
138
|
+
def update_profile(user, options: {})
|
139
|
+
raise "Not a User" unless user.is_a?(Storify::User)
|
140
|
+
|
141
|
+
username = user.username
|
142
|
+
endpoint = Storify::endpoint(version: options[:version],
|
143
|
+
protocol: options[:protocol],
|
144
|
+
method: :update_profile,
|
145
|
+
params: {':username' => username})
|
146
|
+
|
147
|
+
json = user.to_json
|
148
|
+
data = call(endpoint, :POST, params: {:user => json})
|
149
|
+
|
150
|
+
true
|
151
|
+
end
|
152
|
+
|
138
153
|
def publish(story, options: {})
|
139
|
-
|
154
|
+
|
140
155
|
# ensure we have a story w/slug and author
|
141
156
|
raise "Not a Story" unless story.is_a?(Storify::Story)
|
142
157
|
raise "No slug found" if story.slug.nil?
|
@@ -153,7 +168,7 @@ module Storify
|
|
153
168
|
|
154
169
|
# attempt to publish
|
155
170
|
json = story.to_json
|
156
|
-
data = call(endpoint, :POST, params: {:
|
171
|
+
data = call(endpoint, :POST, params: {:story => json})
|
157
172
|
true
|
158
173
|
end
|
159
174
|
|
data/spec/client_spec.rb
CHANGED
@@ -132,19 +132,59 @@ describe Storify::Client do
|
|
132
132
|
@client.publish(story).should == true
|
133
133
|
end
|
134
134
|
|
135
|
-
it "should
|
135
|
+
it "should accept endpoint options" do
|
136
|
+
options = {:version => :v1, :protocol => :insecure}
|
137
|
+
story = @client.story('test-story', @username)
|
138
|
+
@client.publish(story, options: options).should == true
|
139
|
+
end
|
140
|
+
|
141
|
+
it "should allow changes to the story during a publish" do
|
136
142
|
story = @client.story('no-embeds', @username)
|
137
143
|
new_desc = "New Description #{Random.new(Random.new_seed).to_s}"
|
138
|
-
old_desc = story.description
|
139
144
|
|
140
145
|
story.description = new_desc
|
141
146
|
story.description.should == new_desc
|
142
147
|
@client.publish(story).should == true
|
143
148
|
|
144
149
|
revised = @client.story('no-embeds', @username)
|
145
|
-
revised.description.should ==
|
150
|
+
revised.description.should == new_desc
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
context "POST /users/:username/update" do
|
155
|
+
it "should raise an exception if a user is not provided" do
|
156
|
+
expect{@client.update_profile(nil)}.to raise_exception
|
157
|
+
end
|
158
|
+
|
159
|
+
it "should raise an exception if the user cannot be found" do
|
160
|
+
user = Storify::User.new.extend(Storify::UserRepresentable)
|
161
|
+
user.username = "rtejpar$$$$"
|
162
|
+
expect{@client.update_profile(user)}.to raise_exception(Storify::ApiError)
|
146
163
|
end
|
147
164
|
|
165
|
+
it "should raise an exception if the profile cannot be updated" do
|
166
|
+
user = Storify::User.new.extend(Storify::UserRepresentable)
|
167
|
+
user.username = "storify"
|
168
|
+
expect{@client.update_profile(user)}.to raise_exception(Storify::ApiError)
|
169
|
+
end
|
170
|
+
|
171
|
+
it "should accept/reject updates to profile information based on plan status" do
|
172
|
+
user = @client.profile(@username)
|
173
|
+
user.location = "Loc #{Random.new(Random.new_seed).to_s}"
|
174
|
+
|
175
|
+
if user.paid_plan == "free"
|
176
|
+
expect{@client.update_profile(user)}.to raise_exception(Storify::ApiError)
|
177
|
+
else
|
178
|
+
@client.update_profile(user).should == true
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
it "should support endpoint options" do
|
183
|
+
options = {:version => :v1, :protocol => :insecure}
|
184
|
+
user = Storify::User.new.extend(Storify::UserRepresentable)
|
185
|
+
user.username = "rtejpar$$$$"
|
186
|
+
expect{@client.update_profile(user, options: options)}.to raise_exception(Storify::ApiError)
|
187
|
+
end
|
148
188
|
end
|
149
189
|
|
150
190
|
context "Serialization" do
|
data/spec/storify_spec.rb
CHANGED
@@ -85,6 +85,10 @@ describe Storify do
|
|
85
85
|
it "should support the Publish Story endpoint" do
|
86
86
|
Storify::ENDPOINTS[:v1][:publish].should == "/stories/:username/:slug/publish"
|
87
87
|
end
|
88
|
+
|
89
|
+
it "should support the Update User Profile endpoint" do
|
90
|
+
Storify::ENDPOINTS[:v1][:update_profile].should == "/users/:username/update"
|
91
|
+
end
|
88
92
|
end
|
89
93
|
|
90
94
|
context "API Endpoint URI Builder:" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: storify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rizwan Tejpar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|