buttercms-ruby 2.2 → 2.3

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
  SHA256:
3
- metadata.gz: f315c57a5804e6b7817e7f840f85e406ccccd73021ebdfbb5e84e9fad8ea7475
4
- data.tar.gz: aa26b058d512ebf1ff34aa5edef920517a8ba893a775949c1c61b173dc9421a1
3
+ metadata.gz: 71c6d2ca16fa0a3f309ca70b3621a3a120037d0ce4928d1b5ebe8752e5e616b5
4
+ data.tar.gz: 8cdaeb87ff156acb02484dc1aa25f5d05a4a039d699a08a2f6a2206d8b792ee3
5
5
  SHA512:
6
- metadata.gz: b28741a244c0b3ca0e05adc58518754b65fe6d5713ccb6bd22b1948064db992cc894e0fb9b2e1e38df83fc76e996e2aa0cee3f8badc6dd226406fcfc2548610b
7
- data.tar.gz: ac4decef965cc92fadf790ebbb3925a676e3874434c8b192f58f5286aaa10e53dd91d4d74ad6fe28a40fd7c9d5eddc05624719a136fa7167c98847f3d45313ec
6
+ metadata.gz: aee2d3b066ec054493e4a130fbc1e4504609972b537e41630bfc6c58014514405437910c759fe06f3e1380843a230baeb9b8457ea94d9c015708d0507a387599
7
+ data.tar.gz: 73c8720bebf9154a7b18bc1fc07d49937f5fa92a5114842141a0f249e747b03c1f88e8c275f276dc1110b01ff9a3a09f1c5ab3c7e66fc3854d5543fe1a709576
@@ -6,6 +6,9 @@ module ButterCMS
6
6
  # NotFound is raised when a resource cannot be found
7
7
  class NotFound < Error
8
8
  end
9
+
10
+ class Unauthorized < Error
11
+ end
9
12
 
10
13
  class BadRequest < Error
11
14
  end
@@ -1,3 +1,3 @@
1
1
  module ButterCMS
2
- VERSION = '2.2'
2
+ VERSION = '2.3'
3
3
  end
@@ -92,6 +92,8 @@ module ButterCMS
92
92
  case response
93
93
  when Net::HTTPNotFound
94
94
  raise ::ButterCMS::NotFound, JSON.parse(response.body)["detail"]
95
+ when Net::HTTPUnauthorized
96
+ raise ::ButterCMS::Unauthorized, JSON.parse(response.body)['detail']
95
97
  end
96
98
 
97
99
  response.body
@@ -50,5 +50,18 @@ describe ButterCMS do
50
50
 
51
51
  expect(request).to have_been_made
52
52
  end
53
+
54
+ it "raises Unauthorized on 401" do
55
+ allow(ButterCMS).to receive(:api_token).and_return("test")
56
+
57
+ request = stub_request(:get, %r{/posts/slug/})
58
+ .with(query: { auth_token: "test" })
59
+ .to_return(status: 401, body: '{"detail":"Invalid token."}')
60
+
61
+ expect { ButterCMS.request("/posts/slug/") }
62
+ .to raise_error(ButterCMS::Unauthorized)
63
+
64
+ expect(request).to have_been_made
65
+ end
53
66
  end
54
67
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: buttercms-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: '2.2'
4
+ version: '2.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - ButterCMS
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-07 00:00:00.000000000 Z
11
+ date: 2022-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec