her 0.8.4 → 0.8.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0141afc2e4ab0c85094f560968ce2df4913e2424
4
- data.tar.gz: 4bd83da38000aeda38136280b4f655ff0343854d
3
+ metadata.gz: deb396c535f2621118ad4127970ed969edb232c6
4
+ data.tar.gz: f71fbc8a42a9bdf453512adbf6740542ca7a00c8
5
5
  SHA512:
6
- metadata.gz: 1ab620f82e7d16a19856b69b44435fec1feb3dac82848ac985e39a4e11a8567627983280bae0f95ca1802c9f6d51a01dff2c5d00cd81406d34c59f4e7f639669
7
- data.tar.gz: 8da028cf2f7f736c0b02b78423ac7268100411e216bb05f17ee54ce2c89a58b73104e258e99e064313dce48f713bb5dcd175d33783f6fda7357d2c25a344c67d
6
+ metadata.gz: 1a7085472d5a1b1dbcd1981e717a02dd66fa64cad301507f384176c9c48713340c938de866c5c59bef729869d50a0c6c9ffcc8b8e6f8bab53f6f9327a1ee0a40
7
+ data.tar.gz: 48b8ab97ca692b35ec372834e899e8e03123cef0022d91a75ef9058ba96a59fa7321b4bf513865481a35688781151c232b8768a242932db9166d58b594cbd46c
data/README.md CHANGED
@@ -173,6 +173,24 @@ end
173
173
 
174
174
  Now, each HTTP request made by Her will have the `X-API-Token` header.
175
175
 
176
+ ### Basic Http Authentication
177
+ Her can use basic http auth by adding a line to your initializer
178
+
179
+ ```ruby
180
+ # config/initializers/her.rb
181
+ Her::API.setup url: "https://api.example.com" do |c|
182
+ # Request
183
+ c.use Faraday::Request::BasicAuthentication, 'myusername', 'mypassword'
184
+ c.use Faraday::Request::UrlEncoded
185
+
186
+ # Response
187
+ c.use Her::Middleware::DefaultParseJSON
188
+
189
+ # Adapter
190
+ c.use Faraday::Adapter::NetHttp
191
+ end
192
+ ```
193
+
176
194
  ### OAuth
177
195
 
178
196
  Using the `faraday_middleware` and `simple_oauth` gems, it’s fairly easy to use OAuth authentication with Her.
data/lib/her/model/orm.rb CHANGED
@@ -80,7 +80,7 @@ module Her
80
80
  assign_attributes(self.class.parse(parsed_data[:data])) if parsed_data[:data].any?
81
81
  @metadata = parsed_data[:metadata]
82
82
  @response_errors = parsed_data[:errors]
83
- @destroyed = true
83
+ @destroyed = response.success?
84
84
  end
85
85
  end
86
86
  self
@@ -163,7 +163,7 @@ module Her
163
163
  data = parse(parsed_data[:data])
164
164
  metadata = parsed_data[:metadata]
165
165
  response_errors = parsed_data[:errors]
166
- new(data.merge(:_destroyed => true, :metadata => metadata, :response_errors => response_errors))
166
+ new(data.merge(:_destroyed => response.success?, :metadata => metadata, :response_errors => response_errors))
167
167
  end
168
168
  end
169
169
 
data/lib/her/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Her
2
- VERSION = "0.8.4"
2
+ VERSION = "0.8.5"
3
3
  end
@@ -400,13 +400,14 @@ describe Her::Model::ORM do
400
400
  end
401
401
 
402
402
  context "deleting resources" do
403
+ let(:status) { 200 }
403
404
  before do
404
405
  Her::API.setup url: "https://api.example.com" do |builder|
405
406
  builder.use Her::Middleware::FirstLevelParseJSON
406
407
  builder.use Faraday::Request::UrlEncoded
407
408
  builder.adapter :test do |stub|
408
409
  stub.get("/users/1") { [200, {}, { id: 1, fullname: "Tobias Fünke", active: true }.to_json] }
409
- stub.delete("/users/1") { [200, {}, { id: 1, fullname: "Lindsay Fünke", active: false }.to_json] }
410
+ stub.delete("/users/1") { [status, {}, { id: 1, fullname: "Lindsay Fünke", active: false }.to_json] }
410
411
  end
411
412
  end
412
413
 
@@ -426,6 +427,20 @@ describe Her::Model::ORM do
426
427
  expect(@user).to be_destroyed
427
428
  end
428
429
 
430
+ context "with response_errors" do
431
+ let(:status) { 422 }
432
+ it "set user.destroyed to false if errors are present through the .destroy class method" do
433
+ @user = Foo::User.destroy_existing(1)
434
+ expect(@user).not_to be_destroyed
435
+ end
436
+
437
+ it "set user.destroyed to false if errors are present through #destroy on an existing resource" do
438
+ @user = Foo::User.find(1)
439
+ @user.destroy
440
+ expect(@user).not_to be_destroyed
441
+ end
442
+ end
443
+
429
444
  context "with params" do
430
445
  before do
431
446
  Her::API.setup url: "https://api.example.com" do |builder|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: her
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.4
4
+ version: 0.8.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rémi Prévost
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-06 00:00:00.000000000 Z
11
+ date: 2017-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake