restpack-resource 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock
CHANGED
@@ -40,13 +40,13 @@ describe RestPack::Resource do
|
|
40
40
|
|
41
41
|
context "when side-loading" do
|
42
42
|
it "should return related entities with their #as_resource representation" do
|
43
|
-
result = Song.paged_resource(:
|
43
|
+
result = Song.paged_resource(includes: [:users])
|
44
44
|
result[:users][0][:custom].should == 'This is custom data'
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should not allow invalid relations" do
|
48
48
|
expect do
|
49
|
-
Artist.paged_resource(:
|
49
|
+
Artist.paged_resource(includes: [:invalid_relations])
|
50
50
|
end.to raise_error(RestPack::Resource::InvalidInclude, "Artist.invalid_relations is not an includable relation")
|
51
51
|
end
|
52
52
|
|
@@ -54,19 +54,19 @@ describe RestPack::Resource do
|
|
54
54
|
context "ManyToOne" do
|
55
55
|
it "should not allow includes that have not been specified with 'resource_can_include'" do
|
56
56
|
expect do
|
57
|
-
Comment.paged_resource(:
|
57
|
+
Comment.paged_resource(includes: [:songs])
|
58
58
|
end.to raise_error(RestPack::Resource::InvalidInclude, "Comment.songs is not an includable relation")
|
59
59
|
end
|
60
60
|
|
61
61
|
it "should return related entities from a 'belongs_to' relationship" do
|
62
|
-
result = Song.paged_resource(:
|
62
|
+
result = Song.paged_resource(includes: [:artists])
|
63
63
|
result.should_not == nil
|
64
64
|
result[:artists].should_not == nil
|
65
65
|
result[:artists].size.should == 10
|
66
66
|
end
|
67
67
|
|
68
68
|
it "should allow multiple includes" do
|
69
|
-
result = Song.paged_resource(:
|
69
|
+
result = Song.paged_resource(includes: [:artists, :users])
|
70
70
|
result.should_not == nil
|
71
71
|
result[:artists].should_not == nil
|
72
72
|
result[:artists].size.should == 10
|
@@ -82,7 +82,7 @@ describe RestPack::Resource do
|
|
82
82
|
end
|
83
83
|
|
84
84
|
it "should return related entities from a 'has n' relationship" do
|
85
|
-
result = Artist.paged_resource(:
|
85
|
+
result = Artist.paged_resource(includes: [:songs])
|
86
86
|
result.should_not == nil
|
87
87
|
result[:songs].should_not == nil
|
88
88
|
result[:songs].size.should == 11
|