spyke 1.2.0 → 1.2.1
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.
- checksums.yaml +4 -4
- data/README.md +14 -5
- data/lib/spyke/scopes.rb +1 -1
- data/lib/spyke/version.rb +1 -1
- data/test/relation_test.rb +10 -0
- data/test/support/fixtures.rb +5 -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: 9261f1e664c27242d946133701985395af962417
|
4
|
+
data.tar.gz: 11bba7b0d4ca6a79a0066e1faeddf43d19cd339e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bd18ad389c88b9831ea2b028fb2179064283d7b359a0d4cb99ab4d7fb88edefc1f2fabb45993ef4fea00773eb8f36add91610165b3eaa312a61714b3fcb1389
|
7
|
+
data.tar.gz: 8b392cff15ce16f2d473f27aa967bd91121e1a80e78a0cbccef1669ae28791fa6501a07eee81079590eb58c2b302c0097eb202025a1f22e9d217bffd7b5226a3
|
data/README.md
CHANGED
@@ -70,11 +70,20 @@ class User < Spyke::Base
|
|
70
70
|
has_many :posts
|
71
71
|
end
|
72
72
|
|
73
|
-
user = User.find(3)
|
74
|
-
|
75
|
-
|
76
|
-
user.
|
77
|
-
|
73
|
+
user = User.find(3)
|
74
|
+
# => GET http://api.com/users/3
|
75
|
+
|
76
|
+
user.posts
|
77
|
+
# => find embedded in returned JSON or GET http://api.com/users/3/posts
|
78
|
+
|
79
|
+
user.update_attributes(name: 'Alice')
|
80
|
+
# => PUT http://api.com/users/3 - { user: { name: 'Alice' } }
|
81
|
+
|
82
|
+
user.destroy
|
83
|
+
# => DELETE http://api.com/users/3
|
84
|
+
|
85
|
+
User.create(name: 'Bob')
|
86
|
+
# => POST http://api.com/users - { user: { name: 'Bob' } }
|
78
87
|
```
|
79
88
|
|
80
89
|
### Custom URIs
|
data/lib/spyke/scopes.rb
CHANGED
data/lib/spyke/version.rb
CHANGED
data/test/relation_test.rb
CHANGED
@@ -51,6 +51,16 @@ module Spyke
|
|
51
51
|
assert_requested endpoint
|
52
52
|
end
|
53
53
|
|
54
|
+
def test_scope_class_method_doesnt_get_overridden
|
55
|
+
recipe_endpoint = stub_request(:get, 'http://sushi.com/recipes?approved=true')
|
56
|
+
comment_endpoint = stub_request(:get, 'http://sushi.com/comments?comment_approved=true')
|
57
|
+
|
58
|
+
Recipe.approved.to_a
|
59
|
+
assert_requested recipe_endpoint
|
60
|
+
Comment.approved.to_a
|
61
|
+
assert_requested comment_endpoint
|
62
|
+
end
|
63
|
+
|
54
64
|
def test_scope_doesnt_get_stuck
|
55
65
|
endpoint_1 = stub_request(:get, 'http://sushi.com/recipes?per_page=3&status=published')
|
56
66
|
endpoint_2 = stub_request(:get, 'http://sushi.com/recipes?status=published')
|
data/test/support/fixtures.rb
CHANGED
@@ -6,6 +6,7 @@ class Recipe < Spyke::Base
|
|
6
6
|
belongs_to :user
|
7
7
|
|
8
8
|
scope :published, -> { where(status: 'published') }
|
9
|
+
scope :approved, -> { where(approved: true) }
|
9
10
|
attributes :title
|
10
11
|
|
11
12
|
before_save :before_save_callback
|
@@ -63,3 +64,7 @@ end
|
|
63
64
|
class Photo < Spyke::Base
|
64
65
|
uri '/images/photos/:id'
|
65
66
|
end
|
67
|
+
|
68
|
+
class Comment < Spyke::Base
|
69
|
+
scope :approved, -> { where(comment_approved: true) }
|
70
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spyke
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jens Balvig
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|