voog_api 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.rspec +2 -0
- data/Gemfile +3 -0
- data/Guardfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.markdown +55 -0
- data/Rakefile +1 -0
- data/lib/voog_api/api/articles.rb +77 -0
- data/lib/voog_api/api/assets.rb +31 -0
- data/lib/voog_api/api/comments.rb +36 -0
- data/lib/voog_api/api/content_partials.rb +21 -0
- data/lib/voog_api/api/contents.rb +38 -0
- data/lib/voog_api/api/element_definitions.rb +31 -0
- data/lib/voog_api/api/elements.rb +63 -0
- data/lib/voog_api/api/forms.rb +21 -0
- data/lib/voog_api/api/languages.rb +68 -0
- data/lib/voog_api/api/layout_assets.rb +39 -0
- data/lib/voog_api/api/layouts.rb +31 -0
- data/lib/voog_api/api/media_sets.rb +36 -0
- data/lib/voog_api/api/nodes.rb +26 -0
- data/lib/voog_api/api/pages.rb +77 -0
- data/lib/voog_api/api/people.rb +16 -0
- data/lib/voog_api/api/site.rb +35 -0
- data/lib/voog_api/api/tags.rb +26 -0
- data/lib/voog_api/api/texts.rb +21 -0
- data/lib/voog_api/api/tickets.rb +26 -0
- data/lib/voog_api/client.rb +140 -0
- data/lib/voog_api/version.rb +3 -0
- data/lib/voog_api.rb +46 -0
- data/spec/fixtures/articles/article.json +37 -0
- data/spec/fixtures/articles/articles.json +75 -0
- data/spec/fixtures/assets/asset.json +24 -0
- data/spec/fixtures/assets/assets.json +29 -0
- data/spec/fixtures/comments/comment.json +21 -0
- data/spec/fixtures/comments/comments.json +35 -0
- data/spec/fixtures/content_partials/content_partial.json +27 -0
- data/spec/fixtures/content_partials/content_partials.json +47 -0
- data/spec/fixtures/contents/content.json +31 -0
- data/spec/fixtures/contents/contents.json +63 -0
- data/spec/fixtures/element_definitions/element_definition.json +31 -0
- data/spec/fixtures/element_definitions/element_definitions.json +15 -0
- data/spec/fixtures/elements/element.json +35 -0
- data/spec/fixtures/elements/elements.json +57 -0
- data/spec/fixtures/forms/form.json +104 -0
- data/spec/fixtures/forms/forms.json +43 -0
- data/spec/fixtures/languages/language.json +13 -0
- data/spec/fixtures/languages/languages.json +27 -0
- data/spec/fixtures/layout_assets/layout_asset.json +14 -0
- data/spec/fixtures/layout_assets/layout_assets.json +29 -0
- data/spec/fixtures/layouts/layout.json +11 -0
- data/spec/fixtures/layouts/layouts.json +23 -0
- data/spec/fixtures/media_sets/media_set.json +23 -0
- data/spec/fixtures/media_sets/media_sets.json +32 -0
- data/spec/fixtures/nodes/node.json +11 -0
- data/spec/fixtures/nodes/nodes.json +23 -0
- data/spec/fixtures/pages/page.json +73 -0
- data/spec/fixtures/pages/pages.json +104 -0
- data/spec/fixtures/people/people.json +29 -0
- data/spec/fixtures/people/person.json +14 -0
- data/spec/fixtures/site/site.json +30 -0
- data/spec/fixtures/tags/tag.json +20 -0
- data/spec/fixtures/tags/tags.json +31 -0
- data/spec/fixtures/texts/text.json +23 -0
- data/spec/fixtures/texts/texts.json +45 -0
- data/spec/fixtures/tickets/ticket.json +26 -0
- data/spec/fixtures/tickets/tickets.json +29 -0
- data/spec/spec_helper.rb +46 -0
- data/spec/voog_api/api/articles_spec.rb +89 -0
- data/spec/voog_api/api/assets_spec.rb +53 -0
- data/spec/voog_api/api/comments_spec.rb +66 -0
- data/spec/voog_api/api/content_partials_spec.rb +41 -0
- data/spec/voog_api/api/contents_spec.rb +53 -0
- data/spec/voog_api/api/element_definitions_spec.rb +53 -0
- data/spec/voog_api/api/elements_spec.rb +78 -0
- data/spec/voog_api/api/forms_spec.rb +41 -0
- data/spec/voog_api/api/languages_spec.rb +89 -0
- data/spec/voog_api/api/layout_assets_spec.rb +54 -0
- data/spec/voog_api/api/layouts_spec.rb +53 -0
- data/spec/voog_api/api/media_sets_spec.rb +64 -0
- data/spec/voog_api/api/nodes_spec.rb +52 -0
- data/spec/voog_api/api/pages_spec.rb +89 -0
- data/spec/voog_api/api/people_spec.rb +30 -0
- data/spec/voog_api/api/site_spec.rb +53 -0
- data/spec/voog_api/api/tags_spec.rb +53 -0
- data/spec/voog_api/api/texts_spec.rb +41 -0
- data/spec/voog_api/api/tickets_spec.rb +54 -0
- data/spec/voog_spec.rb +38 -0
- data/voog_api.gemspec +27 -0
- metadata +278 -0
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Voog::API::Comments do
|
4
|
+
|
5
|
+
let(:client) { voog_client }
|
6
|
+
|
7
|
+
describe '#comments' do
|
8
|
+
before do
|
9
|
+
request_fixture(:get, 'articles/1/comments', fixture: 'comments/comments')
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'returns a list of comments' do
|
13
|
+
expect(client.comments(1).length).to eql(2)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#comment' do
|
18
|
+
before do
|
19
|
+
request_fixture(:get, 'articles/1/comments/2', fixture: 'comments/comment')
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'returns a single comment' do
|
23
|
+
expect(client.comment(1, 2).body).to eq('Buy something!')
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'returns a comment with the same id as in the request' do
|
27
|
+
expect(client.comment(1, 2).id).to eq(2)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#toggle_spam_comment' do
|
32
|
+
|
33
|
+
before do
|
34
|
+
request_fixture(:put, 'articles/1/comments/2/toggle_spam', response: {body: '{"id": 2, "spam": true}'})
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'responds with new title' do
|
38
|
+
expect(client.toggle_spam_comment(1, 2).spam).to eq(true)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
describe '#delete_comment' do
|
44
|
+
|
45
|
+
before do
|
46
|
+
request_fixture(:delete, 'articles/1/comments/2')
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'calls delete method on comment' do
|
50
|
+
client.delete_comment(1, 2)
|
51
|
+
assert_requested :delete, 'http://voog.test/admin/api/articles/1/comments/2'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#delete_spam_comments' do
|
56
|
+
|
57
|
+
before do
|
58
|
+
request_fixture(:delete, 'articles/1/comments/delete_spam')
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'calls delete_spam method on comment' do
|
62
|
+
client.delete_spam_comments(1)
|
63
|
+
assert_requested :delete, 'http://voog.test/admin/api/articles/1/comments/delete_spam'
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Voog::API::ContentPartials do
|
4
|
+
|
5
|
+
let(:client) { voog_client }
|
6
|
+
|
7
|
+
describe '#content_partials' do
|
8
|
+
before do
|
9
|
+
request_fixture(:get, 'content_partials', fixture: 'content_partials/content_partials')
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'returns a list of content partials' do
|
13
|
+
expect(client.content_partials.length).to eql(2)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#content_partial' do
|
18
|
+
before do
|
19
|
+
request_fixture(:get, 'content_partials/2', fixture: 'content_partials/content_partial')
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'returns a single content partial' do
|
23
|
+
expect(client.content_partial(2).body).to eq('<iframe></iframe>')
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'returns a content_partial with the same id as in the request' do
|
27
|
+
expect(client.content_partial(2).id).to eq(2)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#update_content_partial' do
|
32
|
+
|
33
|
+
before do
|
34
|
+
request_fixture(:put, 'content_partials/2', request: {body: {body: '<object></object>', metainfo: {type: 'custom'}}}, response: {body: '{"id": 2, "content_type": "custom"}'})
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'responds with new autosaved_body' do
|
38
|
+
expect(client.update_content_partial(2, body: '<object></object>', metainfo: {type: 'custom'}).content_type).to eq('custom')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Voog::API::Contents do
|
4
|
+
|
5
|
+
let(:client) { voog_client }
|
6
|
+
|
7
|
+
describe '#contents' do
|
8
|
+
before do
|
9
|
+
request_fixture(:get, 'pages/1/contents', fixture: 'contents/contents')
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'returns a list of contents' do
|
13
|
+
expect(client.contents(Voog::API::Contents::ParentKind::Page, 1).length).to eql(2)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#content' do
|
18
|
+
before do
|
19
|
+
request_fixture(:get, 'pages/1/contents/2', fixture: 'contents/content')
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'returns a single content' do
|
23
|
+
expect(client.content(Voog::API::Contents::ParentKind::Page, 1, 2).name).to eq('slogan')
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'returns a content with the same id as in the request' do
|
27
|
+
expect(client.content(Voog::API::Contents::ParentKind::Page, 1, 2).id).to eq(2)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#delete_content' do
|
32
|
+
|
33
|
+
before do
|
34
|
+
request_fixture(:delete, 'pages/1/contents/2')
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'calls delete method on content' do
|
38
|
+
client.delete_content(Voog::API::Contents::ParentKind::Page, 1, 2)
|
39
|
+
assert_requested :delete, 'http://voog.test/admin/api/pages/1/contents/2'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#move_content' do
|
44
|
+
|
45
|
+
before do
|
46
|
+
request_fixture(:put, 'pages/1/contents/2/move?name=body', response: {body: '{"id": 2, "name": "body"}'})
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'responds with new name' do
|
50
|
+
expect(client.move_content(Voog::API::Contents::ParentKind::Page, 1, 2, name: 'body').name).to eq('body')
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Voog::API::ElementDefinitions do
|
4
|
+
|
5
|
+
let(:client) { voog_client }
|
6
|
+
|
7
|
+
describe '#element_definitions' do
|
8
|
+
before do
|
9
|
+
request_fixture(:get, 'element_definitions', fixture: 'element_definitions/element_definitions')
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'returns a list of element_definitions' do
|
13
|
+
expect(client.element_definitions.length).to eql(2)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#element_definition' do
|
18
|
+
before do
|
19
|
+
request_fixture(:get, 'element_definitions/2', fixture: 'element_definitions/element_definition')
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'returns a single element_definition' do
|
23
|
+
expect(client.element_definition(2).title).to eq('Book')
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'returns a element_definition with the same id as in the request' do
|
27
|
+
expect(client.element_definition(2).id).to eq(2)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#delete_element_definition' do
|
32
|
+
|
33
|
+
before do
|
34
|
+
request_fixture(:delete, 'element_definitions/2')
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'calls delete method on element_definition' do
|
38
|
+
client.delete_element_definition(2)
|
39
|
+
assert_requested :delete, 'http://voog.test/admin/api/element_definitions/2'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#update_element_definition' do
|
44
|
+
|
45
|
+
before do
|
46
|
+
request_fixture(:put, 'element_definitions/2', request: {body: {title: 'Fiction book'}}, response: {body: '{"id": 2, "title": "Fiction book"}'})
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'responds with new title' do
|
50
|
+
expect(client.update_element_definition(2, title: 'Fiction book').title).to eq('Fiction book')
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Voog::API::Elements do
|
4
|
+
|
5
|
+
let(:client) { voog_client }
|
6
|
+
|
7
|
+
describe '#elements' do
|
8
|
+
before do
|
9
|
+
request_fixture(:get, 'elements', fixture: 'elements/elements')
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'returns a list of elements' do
|
13
|
+
expect(client.elements.length).to eql(2)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#element' do
|
18
|
+
before do
|
19
|
+
request_fixture(:get, 'elements/1', fixture: 'elements/element')
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'returns a single element' do
|
23
|
+
expect(client.element(1).title).to eq('Marilyn Monroe')
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'returns a element with the same id as in the request' do
|
27
|
+
expect(client.element(1).id).to eq(1)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#delete_element' do
|
32
|
+
|
33
|
+
before do
|
34
|
+
request_fixture(:delete, 'elements/2')
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'calls delete method on element' do
|
38
|
+
client.delete_element(2)
|
39
|
+
assert_requested :delete, 'http://voog.test/admin/api/elements/2'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#update_element' do
|
44
|
+
|
45
|
+
before do
|
46
|
+
request_fixture(:put, 'elements/2', request: {body: {title: 'Marilyn Monroe I'}}, response: {body: '{"id": 2, "title": "Marilyn Monroe I"}'})
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'responds with new title' do
|
50
|
+
expect(client.update_element(2, title: 'Marilyn Monroe I').title).to eq('Marilyn Monroe I')
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe '#move_element' do
|
55
|
+
|
56
|
+
before do
|
57
|
+
request_fixture(:put, 'elements/1/move?page_id=2', response: {body: '{"id": 3, "page": {"id": 2}, "position": 1}'})
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'responds with parent_id' do
|
61
|
+
expect(client.move_element(1, page_id: 2).page.id).to eq(2)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '#element_content' do
|
66
|
+
before do
|
67
|
+
request_fixture(:get, 'elements/1/contents/2', fixture: 'contents/content')
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'returns a single content' do
|
71
|
+
expect(client.content(Voog::API::Contents::ParentKind::Element, 1, 2).name).to eq('slogan')
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'returns a content with the same id as in the request' do
|
75
|
+
expect(client.content(Voog::API::Contents::ParentKind::Element, 1, 2).id).to eq(2)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Voog::API::Forms do
|
4
|
+
|
5
|
+
let(:client) { voog_client }
|
6
|
+
|
7
|
+
describe '#forms' do
|
8
|
+
before do
|
9
|
+
request_fixture(:get, 'forms', fixture: 'forms/forms')
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'returns a list of forms' do
|
13
|
+
expect(client.forms.length).to eql(2)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#form' do
|
18
|
+
before do
|
19
|
+
request_fixture(:get, 'forms/2', fixture: 'forms/form')
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'returns a single form' do
|
23
|
+
expect(client.form(2).title).to eq('Contact')
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'returns a form with the same id as in the request' do
|
27
|
+
expect(client.form(2).id).to eq(2)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#update_form' do
|
32
|
+
|
33
|
+
before do
|
34
|
+
request_fixture(:put, 'forms/2', request: {body: {title: 'Updated title', submit_label: 'Send!'}}, response: {body: '{"id": 2, "title": "Updated title", "submit_label": "Send!"}'})
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'responds with new title' do
|
38
|
+
expect(client.update_form(2, title: 'Updated title', submit_label: 'Send!').title).to eq('Updated title')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Voog::API::Languages do
|
4
|
+
|
5
|
+
let(:client) { voog_client }
|
6
|
+
|
7
|
+
describe '#languages' do
|
8
|
+
before do
|
9
|
+
request_fixture(:get, 'languages', fixture: 'languages/languages')
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'returns a list of languages' do
|
13
|
+
expect(client.languages.length).to eql(2)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#language' do
|
18
|
+
before do
|
19
|
+
request_fixture(:get, 'languages/2', fixture: 'languages/language')
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'returns a single language' do
|
23
|
+
expect(client.language(2).title).to eq('FRA')
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'returns a language with the same id as in the request' do
|
27
|
+
expect(client.language(2).id).to eq(2)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#delete_language' do
|
32
|
+
|
33
|
+
before do
|
34
|
+
request_fixture(:delete, 'languages/2')
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'calls delete method on language' do
|
38
|
+
client.delete_language(2)
|
39
|
+
assert_requested :delete, 'http://voog.test/admin/api/languages/2'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#update_language' do
|
44
|
+
|
45
|
+
before do
|
46
|
+
request_fixture(:put, 'languages/2', request: {body: {title: 'FR'}}, response: {body: '{"id": 2, "title": "FR"}'})
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'responds with new title' do
|
50
|
+
expect(client.update_language(2, title: 'FR').title).to eq('FR')
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe '#move_language' do
|
55
|
+
|
56
|
+
before do
|
57
|
+
request_fixture(:put, 'languages/2/move?before=1', response: {body: '{"id": 2, "position": 1}'})
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'responds with new position' do
|
61
|
+
expect(client.move_language(2, before: 1).position).to eq(1)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '#enable_language_autodetect' do
|
66
|
+
|
67
|
+
before do
|
68
|
+
request_fixture(:put, 'languages/enable_autodetect')
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'responds body should be empty' do
|
72
|
+
expect(client.enable_language_autodetect).to be_nil
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe '#language_content' do
|
77
|
+
before do
|
78
|
+
request_fixture(:get, 'languages/1/contents/2', fixture: 'contents/content')
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'returns a single content' do
|
82
|
+
expect(client.content(Voog::API::Contents::ParentKind::Language, 1, 2).name).to eq('slogan')
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'returns a content with the same id as in the request' do
|
86
|
+
expect(client.content(Voog::API::Contents::ParentKind::Language, 1, 2).id).to eq(2)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Voog::API::LayoutAssets do
|
4
|
+
|
5
|
+
let(:client) { voog_client }
|
6
|
+
|
7
|
+
describe '#layout_assets' do
|
8
|
+
before do
|
9
|
+
request_fixture(:get, 'layout_assets', fixture: 'layout_assets/layout_assets')
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'returns a list of layout_assets' do
|
13
|
+
expect(client.layout_assets.length).to eq(2)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#layout_asset' do
|
18
|
+
before do
|
19
|
+
request_fixture(:get, 'layout_assets/2', fixture: 'layout_assets/layout_asset')
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'returns a single layout_asset' do
|
23
|
+
expect(client.layout_asset(2).filename).to eq('style.css')
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'returns a layout_asset with the same id as in the request' do
|
27
|
+
expect(client.layout_asset(2).id).to eql(2)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#delete_layout_asset' do
|
33
|
+
|
34
|
+
before do
|
35
|
+
request_fixture(:delete, 'layout_assets/2')
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'calls delete method on layout asset' do
|
39
|
+
client.delete_layout_asset(2)
|
40
|
+
assert_requested :delete, voog_url('layout_assets/2')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '#update_layout_asset' do
|
45
|
+
|
46
|
+
before do
|
47
|
+
request_fixture(:put, 'layout_assets/2', request: {body: {filename: 'new_asset.css'}}, response: {body: '{"id": 2, "filename": "new_asset.css"}'})
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'changes filename' do
|
51
|
+
expect(client.update_layout_asset(2, filename: 'new_asset.css').filename).to eq('new_asset.css')
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Voog::API::Layouts do
|
4
|
+
|
5
|
+
let(:client) { voog_client }
|
6
|
+
|
7
|
+
describe '#layouts' do
|
8
|
+
before do
|
9
|
+
request_fixture(:get, 'layouts', fixture: 'layouts/layouts')
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'returns a list of layouts' do
|
13
|
+
expect(client.layouts.length).to eql(2)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#layout' do
|
18
|
+
before do
|
19
|
+
request_fixture(:get, 'layouts/2', fixture: 'layouts/layout')
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'returns a single layout' do
|
23
|
+
expect(client.layout(2).title).to eq('Blog & News')
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'returns a layout with the same id as in the request' do
|
27
|
+
expect(client.layout(2).id).to eq(2)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#delete_layout' do
|
32
|
+
|
33
|
+
before do
|
34
|
+
request_fixture(:delete, 'layouts/2')
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'calls delete method on layout' do
|
38
|
+
client.delete_layout(2)
|
39
|
+
assert_requested :delete, 'http://voog.test/admin/api/layouts/2'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#update_layout' do
|
44
|
+
|
45
|
+
before do
|
46
|
+
request_fixture(:put, 'layouts/2', request: {body: {title: 'Updated title'}}, response: {body: '{"id": 2, "title": "Updated title"}'})
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'responds with new title' do
|
50
|
+
expect(client.update_layout(2, title: 'Updated title').title).to eq('Updated title')
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Voog::API::MediaSets do
|
4
|
+
|
5
|
+
let(:client) { voog_client }
|
6
|
+
|
7
|
+
describe '#media_sets' do
|
8
|
+
before do
|
9
|
+
request_fixture(:get, 'media_sets', fixture: 'media_sets/media_sets')
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'returns a list of media_sets' do
|
13
|
+
expect(client.media_sets.length).to eql(2)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#media_set' do
|
18
|
+
before do
|
19
|
+
request_fixture(:get, 'media_sets/2', fixture: 'media_sets/media_set')
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'returns a single media_set' do
|
23
|
+
expect(client.media_set(2).title).to eq('Standalone media set')
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'returns a media_set with the same id as in the request' do
|
27
|
+
expect(client.media_set(2).id).to eq(2)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#delete_media_set' do
|
32
|
+
|
33
|
+
before do
|
34
|
+
request_fixture(:delete, 'media_sets/2')
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'calls delete method on media_set' do
|
38
|
+
client.delete_media_set(2)
|
39
|
+
assert_requested :delete, 'http://voog.test/admin/api/media_sets/2'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#update_media_set' do
|
44
|
+
|
45
|
+
before do
|
46
|
+
request_fixture(:put, 'media_sets/2', request: {body: {title: 'Updated title'}}, response: {body: '{"id": 2, "title": "Updated title"}'})
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'responds with new title' do
|
50
|
+
expect(client.update_media_set(2, title: 'Updated title').title).to eq('Updated title')
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe '#media_set_add_assets' do
|
55
|
+
|
56
|
+
before do
|
57
|
+
request_fixture(:put, 'media_sets/2/add_assets', request: {body: {asset_ids: [5, 8]}}, response: {body: '{"id": 2, "assets": [{"id": 1}, {"id": 5}, {"id": 8}]}'})
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'responds with correct assets set' do
|
61
|
+
expect(client.media_set_add_assets(2, asset_ids: [5, 8]).assets.map(&:id)).to eq([1, 5, 8])
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Voog::API::Nodes do
|
4
|
+
|
5
|
+
let(:client) { voog_client }
|
6
|
+
|
7
|
+
describe '#nodes' do
|
8
|
+
before do
|
9
|
+
request_fixture(:get, 'nodes', fixture: 'nodes/nodes')
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'returns a list of nodes' do
|
13
|
+
expect(client.nodes.length).to eql(2)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#node' do
|
18
|
+
before do
|
19
|
+
request_fixture(:get, 'nodes/2', fixture: 'nodes/node')
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'returns a single node' do
|
23
|
+
expect(client.node(2).title).to eq('Products')
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'returns a node with the same id as in the request' do
|
27
|
+
expect(client.node(2).id).to eq(2)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#update_node' do
|
32
|
+
|
33
|
+
before do
|
34
|
+
request_fixture(:put, 'nodes/2', request: {body: {title: 'About us'}}, response: {body: '{"id": 2, "title": "About us"}'})
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'responds with new title' do
|
38
|
+
expect(client.update_node(2, title: 'About us').title).to eq('About us')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#move_node' do
|
43
|
+
|
44
|
+
before do
|
45
|
+
request_fixture(:put, 'nodes/3/move?parent_id=2', response: {body: '{"id": 3, "parent_id": 2, "position": 1}'})
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'responds with parent_id' do
|
49
|
+
expect(client.move_node(3, parent_id: 2).parent_id).to eq(2)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|