collection-json-browser 0.0.9 → 0.0.10
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/app/assets/javascripts/collection_json_browser/angular/controllers/api_controller.js +49 -4
- data/app/views/collection_json_browser/home/index.html +10 -2
- data/lib/collection-json-browser/version.rb +1 -1
- data/test/dummy/log/development.log +17812 -0
- data/test/dummy/tmp/cache/assets/CC8/CC0/sprockets%2F77ac1342b1ae62c0123f399257a703aa +0 -0
- data/test/dummy/tmp/cache/assets/D01/390/sprockets%2F152365a6c64bdbf13d80c22762c0f48b +0 -0
- data/test/dummy/tmp/cache/assets/D36/D00/sprockets%2F3a43e8f11605c939cbb04aec364ba775 +0 -0
- data/test/dummy/tmp/cache/assets/D58/C00/sprockets%2F7bd61bb28f7ce577f679872a7cc4a477 +0 -0
- data/test/dummy/tmp/cache/assets/D74/650/sprockets%2F5c448233c8ef782e60adda4b8f572b6b +0 -0
- data/test/javascripts/test/unit/controllersSpec.js +67 -3
- metadata +2 -2
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -13,20 +13,42 @@ describe('ApiController', function(){
|
|
13
13
|
rel: "My cat is cooler",
|
14
14
|
render: "image"
|
15
15
|
};
|
16
|
+
|
16
17
|
var responseData = {
|
17
18
|
collection: {
|
18
19
|
version: "1.0",
|
19
20
|
href: "/api",
|
20
21
|
links: [ link, image ],
|
22
|
+
items: [ getItem(1), getItem(2) ],
|
21
23
|
template: {
|
22
24
|
data: [
|
23
|
-
{
|
24
|
-
|
25
|
+
{
|
26
|
+
name: "title",
|
27
|
+
prompt: "Post title",
|
28
|
+
value: ""
|
29
|
+
},
|
30
|
+
{
|
31
|
+
name: "tag",
|
32
|
+
value: ""
|
33
|
+
},
|
25
34
|
]
|
26
35
|
}
|
27
36
|
}
|
28
37
|
}
|
29
38
|
|
39
|
+
function getItem(i){
|
40
|
+
return {
|
41
|
+
href: "/api/posts/" + i,
|
42
|
+
rel: "post",
|
43
|
+
prompt: "Post",
|
44
|
+
data: [{
|
45
|
+
name: "title",
|
46
|
+
prompt: "Post title",
|
47
|
+
value: "awesome post " + i
|
48
|
+
}]
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
30
52
|
beforeEach(inject(function(_$httpBackend_, $location, $rootScope, $controller) {
|
31
53
|
$httpBackend = _$httpBackend_;
|
32
54
|
var root = "http://localhost:3000"
|
@@ -55,6 +77,47 @@ describe('ApiController', function(){
|
|
55
77
|
expect(JSON.parse(scope.raw)).toEqual(responseData);
|
56
78
|
});
|
57
79
|
|
80
|
+
describe('template', function(){
|
81
|
+
var t;
|
82
|
+
beforeEach(function(){
|
83
|
+
t = responseData.collection.template
|
84
|
+
})
|
85
|
+
|
86
|
+
it('sets the template from response data', function() {
|
87
|
+
expect(scope.template).toBeUndefined();
|
88
|
+
$httpBackend.flush();
|
89
|
+
|
90
|
+
expect(scope.template).toEqual(responseData.collection.template.data);
|
91
|
+
});
|
92
|
+
|
93
|
+
it('assigns undefined when response data does not contain template', function() {
|
94
|
+
responseData.collection.template = undefined
|
95
|
+
scope.template = t
|
96
|
+
$httpBackend.flush();
|
97
|
+
|
98
|
+
expect(scope.template).toBeUndefined();
|
99
|
+
});
|
100
|
+
|
101
|
+
afterEach(function(){
|
102
|
+
responseData.collection.template = t
|
103
|
+
})
|
104
|
+
})
|
105
|
+
|
106
|
+
it('sets the itemPaths from response data', function() {
|
107
|
+
expect(scope.itemPaths).toBeUndefined();
|
108
|
+
$httpBackend.flush();
|
109
|
+
|
110
|
+
var href1 = getItem(1).href
|
111
|
+
var href2 = getItem(2).href
|
112
|
+
expect(scope.itemPaths).toEqual(
|
113
|
+
[
|
114
|
+
{name: "-- None (POST create) --", value: ""},
|
115
|
+
{name: href1, value: href1},
|
116
|
+
{name: href2, value: href2}
|
117
|
+
]
|
118
|
+
);
|
119
|
+
});
|
120
|
+
|
58
121
|
it('sets location path', function(){
|
59
122
|
expect(location.path()).toEqual('');
|
60
123
|
$httpBackend.flush();
|
@@ -87,6 +150,7 @@ describe('ApiController', function(){
|
|
87
150
|
it('post the form when fromRel is not edit-form', function(){
|
88
151
|
$httpBackend.expectPOST('/api')
|
89
152
|
|
153
|
+
scope.template = responseData.collection.template.data
|
90
154
|
scope.fromRel = 'some-stuff'
|
91
155
|
scope.submit()
|
92
156
|
|
@@ -94,9 +158,9 @@ describe('ApiController', function(){
|
|
94
158
|
})
|
95
159
|
|
96
160
|
it('put the form when fromRel is edit-form', function(){
|
97
|
-
spyOn(location, 'url').andReturn('/api/posts/1')
|
98
161
|
$httpBackend.expectPUT('/api/posts/1')
|
99
162
|
|
163
|
+
scope.template = responseData.collection.template.data
|
100
164
|
scope.fromRel = 'edit-form'
|
101
165
|
scope.submit()
|
102
166
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: collection-json-browser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-09-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|