parse_resource 1.7.2 → 1.7.3
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.
- data/.travis.yml +6 -0
- data/Gemfile +5 -1
- data/Gemfile.lock +11 -1
- data/README.md +21 -8
- data/VERSION +1 -1
- data/fixtures/vcr_cassettes/test_all.yml +161 -0
- data/fixtures/vcr_cassettes/test_attribute_getters.yml +57 -0
- data/fixtures/vcr_cassettes/test_attribute_setters.yml +57 -0
- data/fixtures/vcr_cassettes/test_authenticate.yml +155 -0
- data/fixtures/vcr_cassettes/test_chained_wheres.yml +161 -0
- data/fixtures/vcr_cassettes/test_count.yml +411 -0
- data/fixtures/vcr_cassettes/test_create.yml +57 -0
- data/fixtures/vcr_cassettes/test_created_at.yml +57 -0
- data/fixtures/vcr_cassettes/test_destroy.yml +157 -0
- data/fixtures/vcr_cassettes/test_destroy_all.yml +207 -0
- data/fixtures/vcr_cassettes/test_each.yml +269 -0
- data/fixtures/vcr_cassettes/test_find.yml +107 -0
- data/fixtures/vcr_cassettes/test_find_all_by.yml +157 -0
- data/fixtures/vcr_cassettes/test_find_by.yml +157 -0
- data/fixtures/vcr_cassettes/test_first.yml +107 -0
- data/fixtures/vcr_cassettes/test_id.yml +57 -0
- data/fixtures/vcr_cassettes/test_limit.yml +864 -0
- data/fixtures/vcr_cassettes/test_map.yml +269 -0
- data/fixtures/vcr_cassettes/test_save.yml +111 -0
- data/fixtures/vcr_cassettes/test_skip.yml +843 -0
- data/fixtures/vcr_cassettes/test_update.yml +111 -0
- data/fixtures/vcr_cassettes/test_updated_at.yml +111 -0
- data/fixtures/vcr_cassettes/test_username_should_be_unique.yml +109 -0
- data/fixtures/vcr_cassettes/test_where.yml +107 -0
- data/lib/parse_resource/base.rb +66 -69
- data/lib/parse_resource/parse_user.rb +1 -1
- data/lib/parse_resource/query.rb +9 -9
- data/parse_resource.gemspec +41 -7
- data/parse_resource.yml +12 -0
- data/test/active_model_lint_test.rb +5 -6
- data/test/helper.rb +8 -0
- data/test/test_parse_resource.rb +183 -117
- data/test/test_parse_user.rb +39 -32
- data/test/test_query_options.rb +43 -17
- metadata +149 -26
- data/test/test_associations.rb +0 -105
data/test/test_associations.rb
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
require 'parse_resource'
|
3
|
-
|
4
|
-
path = "parse_resource.yml"
|
5
|
-
settings = YAML.load(ERB.new(File.new(path).read).result)['test']
|
6
|
-
|
7
|
-
ParseResource::Base.load!(settings['app_id'], settings['master_key'])
|
8
|
-
|
9
|
-
class Post < ParseResource::Base
|
10
|
-
belongs_to :author
|
11
|
-
fields :title, :body
|
12
|
-
end
|
13
|
-
|
14
|
-
class Author < ParseResource::Base
|
15
|
-
has_many :posts
|
16
|
-
field :name
|
17
|
-
end
|
18
|
-
|
19
|
-
class TestAssociations < Test::Unit::TestCase
|
20
|
-
|
21
|
-
def setup
|
22
|
-
Post.destroy_all
|
23
|
-
Author.destroy_all
|
24
|
-
end
|
25
|
-
|
26
|
-
|
27
|
-
def teardown
|
28
|
-
Post.destroy_all
|
29
|
-
Author.destroy_all
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_responds_to_has_many
|
33
|
-
#author = Author.create(:name => "alan")
|
34
|
-
author = Author.new
|
35
|
-
assert_equal true, author.respond_to?(:posts)
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_has_many_returns_an_array
|
39
|
-
author = Author.create(:name => "alex")
|
40
|
-
assert_equal true, author.posts.is_a?(Array)
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_relational_query
|
44
|
-
a = Author.create(:name => "JK Rowling_relational_query")
|
45
|
-
p = Post.create(:title => "test relational query")
|
46
|
-
p.author = a#.to_pointer
|
47
|
-
p.save
|
48
|
-
post = Post.include_object(:author).where(:title => "test relational query").first
|
49
|
-
assert_equal Post, post.class
|
50
|
-
assert_equal "Object", post.attributes['author']['__type']
|
51
|
-
assert_equal "Author", post.attributes['author']['className']
|
52
|
-
assert_equal a.id, post.attributes['author']['objectId']
|
53
|
-
assert_equal a.name, post.attributes['author']['name']
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_to_pointer_duck_typing
|
57
|
-
a = Author.create(:name => "Duck")
|
58
|
-
p = Post.create(:title => "Typing")
|
59
|
-
p.author = a
|
60
|
-
p.save
|
61
|
-
assert_equal p.author.name, a.name
|
62
|
-
assert_equal a.posts.class, Array
|
63
|
-
assert_equal a.posts.length, 1
|
64
|
-
assert_equal a.posts[0].class, Post
|
65
|
-
assert_equal a.posts[0].id, p.id
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_has_many_parent_getter
|
69
|
-
a = Author.create(:name => "RL Stine")
|
70
|
-
p = Post.create(:title => "Goosebumps_has_many_parent_getter")
|
71
|
-
p.author = a#.to_pointer
|
72
|
-
p.save
|
73
|
-
assert_equal Array, a.posts.class
|
74
|
-
assert_equal Post, a.posts.first.class
|
75
|
-
assert_equal p.title, a.posts.first.title
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_has_many_child_getter
|
79
|
-
a = Author.create(:name => "JK Rowling_child_getter")
|
80
|
-
p = Post.create(:title => "test has_many child getter")
|
81
|
-
p.author = a.to_pointer
|
82
|
-
p.save
|
83
|
-
assert_equal p.author.id, a.id
|
84
|
-
end
|
85
|
-
|
86
|
-
def test_belongs_to_setter
|
87
|
-
Author.destroy_all
|
88
|
-
Post.destroy_all
|
89
|
-
aa = Author.create(:name => "Shmalter Kirn")
|
90
|
-
pp = Post.create(:title => "Shmup in the Air")
|
91
|
-
pp.author = aa#.to_pointer
|
92
|
-
pp.save
|
93
|
-
assert aa.id
|
94
|
-
assert_equal aa.id, pp.author.id
|
95
|
-
end
|
96
|
-
|
97
|
-
def test_has_many_setter
|
98
|
-
author = Author.create(:name => "R.L. Stine")
|
99
|
-
post = Post.create(:title => "Goosebumps_has_many_setter")
|
100
|
-
author.posts << post
|
101
|
-
assert_equal true, (author.posts.length > 0)
|
102
|
-
assert_equal Post, author.posts[0].class
|
103
|
-
end
|
104
|
-
|
105
|
-
end
|