constructor-cms 0.6.1 → 0.6.2
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/Gemfile +3 -1
- data/Guardfile +1 -3
- data/constructor-cms.gemspec +1 -0
- data/core/app/controllers/constructor_core/users_controller.rb +0 -2
- data/core/app/views/constructor_core/sessions/new.html.haml +5 -5
- data/core/app/views/constructor_core/users/profile.haml +3 -3
- data/core/app/views/layouts/constructor_core/application.haml +12 -12
- data/core/config/routes.rb +1 -1
- data/core/lib/constructor_core/version.rb +1 -1
- data/lib/constructor-cms/engine.rb +1 -1
- data/pages/app/controllers/constructor_pages/pages_controller.rb +11 -6
- data/pages/app/controllers/constructor_pages/templates_controller.rb +2 -1
- data/pages/app/helpers/constructor_pages/move_helper.rb +2 -2
- data/pages/app/helpers/constructor_pages/pages_helper.rb +2 -0
- data/pages/app/helpers/constructor_pages/templates_helper.rb +2 -0
- data/pages/app/helpers/constructor_pages/treeview_helper.rb +33 -0
- data/pages/app/models/constructor_pages/page.rb +4 -2
- data/pages/app/views/constructor_pages/fields/_form.haml +10 -10
- data/pages/app/views/constructor_pages/fields/types/_html.haml +1 -1
- data/pages/app/views/constructor_pages/fields/types/_image.haml +1 -1
- data/pages/app/views/constructor_pages/fields/types/_integer.haml +1 -1
- data/pages/app/views/constructor_pages/fields/types/_string.haml +1 -1
- data/pages/app/views/constructor_pages/fields/types/_text.haml +1 -1
- data/pages/app/views/constructor_pages/pages/_breadcrumbs.haml +2 -2
- data/pages/app/views/constructor_pages/pages/_form.haml +30 -30
- data/pages/app/views/constructor_pages/pages/index.haml +35 -45
- data/pages/app/views/constructor_pages/partials/_arrow_buttons.haml +6 -0
- data/pages/app/views/constructor_pages/templates/_form.haml +23 -18
- data/pages/app/views/constructor_pages/templates/index.haml +11 -30
- data/pages/config/locales/en.yml +1 -0
- data/pages/config/locales/ru.yml +1 -0
- data/pages/config/routes.rb +16 -21
- data/pages/spec/features/constructor_pages/pages_controller_spec.rb +280 -0
- data/pages/spec/models/constructor_pages/field_model_spec.rb +12 -16
- data/pages/spec/models/constructor_pages/page_model_spec.rb +2 -1
- data/pages/spec/models/constructor_pages/template_model_spec.rb +1 -1
- data/spec/dummy/config/environment.rb +0 -2
- data/spec/spec_helper.rb +5 -0
- metadata +23 -7
- data/pages/spec/requests/constructor_pages/pages_controller_spec.rb +0 -12
@@ -2,51 +2,41 @@
|
|
2
2
|
=t :structure
|
3
3
|
|
4
4
|
- content_for :actions do
|
5
|
-
|
6
|
-
|
5
|
+
- if @template_exists
|
6
|
+
.span4.clearfix.text-right
|
7
|
+
= link_to pages.new_page_path, class: 'btn btn-large btn-link' do
|
8
|
+
%i.icon-plus
|
9
|
+
=t :new_page
|
7
10
|
|
8
11
|
%section.b-tree.span12
|
9
12
|
%ul
|
10
|
-
|
11
|
-
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
=
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
-
|
39
|
-
|
40
|
-
- if !page.template.leaf?
|
41
|
-
= link_to "<i class='icon-chevron-down'></i> #{t :add} #{page.template.descendants.first.name.downcase}".html_safe, new_child_page_path(page), :class => "btn btn-success btn-mini"
|
42
|
-
- else
|
43
|
-
= link_to "<i class='icon-chevron-down'></i> #{t :add} #{ConstructorPages::Template.find(page.template.child_id).name.downcase}".html_safe, new_child_page_path(page), :class => "btn btn-success btn-mini"
|
44
|
-
|
45
|
-
= link_to "<i class='icon-remove'></i> #{t :delete}".html_safe, page_path(page), method: :delete, class: 'btn btn-danger btn-mini pull-right', data: {confirm: t(:are_you_sure?)}
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
- level = page.level
|
50
|
-
- last_page = page
|
51
|
-
</li>
|
52
|
-
= raw "</ul></li>" * last_page.level
|
13
|
+
= render_tree @roots do |page|
|
14
|
+
- if page.published?
|
15
|
+
= link_to page.name, page.full_url, class: 'btn btn-link'
|
16
|
+
- else
|
17
|
+
%button.btn.disabled= page.name
|
18
|
+
|
19
|
+
.b-tree__buttons
|
20
|
+
= render partial: 'constructor_pages/partials/arrow_buttons', locals: {item: page}
|
21
|
+
|
22
|
+
= link_to edit_page_path(page), class: 'btn btn-primary btn-mini' do
|
23
|
+
%i.icon-pencil
|
24
|
+
=t :edit
|
25
|
+
= page.template.name.downcase
|
26
|
+
|
27
|
+
- unless page.template.nil?
|
28
|
+
- if page.template.child_id.nil?
|
29
|
+
- if !page.template.leaf?
|
30
|
+
= link_to new_child_page_path(page), class: 'btn btn-success btn-mini' do
|
31
|
+
%i.icon-chevron-down
|
32
|
+
=t :add
|
33
|
+
= page.template.descendants.first.name.downcase
|
34
|
+
- else
|
35
|
+
= link_to new_child_page_path(page), class: 'btn btn-success btn-mini' do
|
36
|
+
%i.icon-chevron-down
|
37
|
+
=t :add
|
38
|
+
= ConstructorPages::Template.find(page.template.child_id).name.downcase
|
39
|
+
|
40
|
+
= link_to page_path(page), method: :delete, class: 'btn btn-danger btn-mini pull-right', data: {confirm: t(:are_you_sure?)} do
|
41
|
+
%i.icon-remove
|
42
|
+
=t :delete
|
@@ -0,0 +1,6 @@
|
|
1
|
+
.btn-group
|
2
|
+
- {down: :right, up: :left}.each_pair do |a, b|
|
3
|
+
- sibling = item.send(b.to_s+'_sibling')
|
4
|
+
- if sibling and item.move_possible?(sibling)
|
5
|
+
= link_to "/admin/#{item.class.to_s.demodulize.downcase.pluralize}/move/#{a}/#{item.id}", class: 'btn btn-mini' do
|
6
|
+
%i{class: "icon-arrow-#{a}"}
|
@@ -1,47 +1,52 @@
|
|
1
1
|
= form_for @template do |f|
|
2
2
|
- if @template.errors.any?
|
3
3
|
.alert.alert-error.fade.in.span12
|
4
|
-
= link_to
|
4
|
+
= link_to '×', '#', class: 'close', 'data-dismiss' => 'alert'
|
5
5
|
- @template.errors.full_messages.each do |m|
|
6
6
|
= m
|
7
7
|
|
8
8
|
.form-horizontal
|
9
9
|
.control-group
|
10
|
-
= f.label :name, :
|
11
|
-
.controls= f.text_field :name, :
|
10
|
+
= f.label :name, class: 'control-label'
|
11
|
+
.controls= f.text_field :name, class: 'span4'
|
12
12
|
|
13
13
|
.control-group
|
14
|
-
= f.label :code_name, :
|
15
|
-
.controls= f.text_field :code_name, :
|
14
|
+
= f.label :code_name, class: 'control-label'
|
15
|
+
.controls= f.text_field :code_name, class: 'span4'
|
16
16
|
|
17
17
|
.control-group
|
18
|
-
= f.label :parent, :
|
18
|
+
= f.label :parent, class: 'control-label'
|
19
19
|
.controls
|
20
|
-
= f.select :parent_id, options_for_select(for_select(@roots), :
|
20
|
+
= f.select :parent_id, options_for_select(for_select(@roots), selected: @template.parent_id), disabled: @template.self_and_descendants.map(&:id), include_blank: t(:no)
|
21
21
|
|
22
22
|
.control-group
|
23
|
-
= f.label :child, :
|
23
|
+
= f.label :child, class: 'control-label'
|
24
24
|
.controls
|
25
|
-
= f.select :child_id, options_for_select(for_select(@roots), :
|
25
|
+
= f.select :child_id, options_for_select(for_select(@roots), selected: @template.child_id), include_blank: t(:no)
|
26
26
|
|
27
27
|
- unless @template.new_record?
|
28
28
|
.control-group
|
29
29
|
.controls
|
30
|
-
= link_to
|
30
|
+
= link_to new_field_path(@template.id), class: 'btn btn-mini btn-link' do
|
31
|
+
%i.icon-plus
|
32
|
+
=t :new_field
|
31
33
|
|
32
34
|
- @template.fields.each do |field|
|
33
35
|
.control-group
|
34
|
-
= label_tag
|
36
|
+
= label_tag '', field.name, class: 'control-label'
|
35
37
|
.controls
|
36
|
-
= link_to
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
= link_to
|
38
|
+
= link_to field_move_down_path(field), class: "btn btn-mini #{'disabled' if field.last?}" do
|
39
|
+
%i.icon-arrow-down
|
40
|
+
= link_to field_move_up_path(field), class: "btn btn-mini #{'disabled' if field.first?}" do
|
41
|
+
%i.icon-arrow-up
|
42
|
+
= link_to edit_field_path(field, field.template), class: 'btn btn-mini btn-primary' do
|
43
|
+
%i.icon-pencil
|
44
|
+
= link_to field_path(field), method: :delete, data: {confirm: t(:are_you_sure?)}, class: 'btn btn-mini btn-danger' do
|
45
|
+
%i.icon-remove
|
41
46
|
|
42
47
|
.row-fluid
|
43
48
|
.span12
|
44
49
|
.form-actions
|
45
|
-
= f.submit :
|
46
|
-
= link_to t(:cancel), templates_url, :
|
50
|
+
= f.submit class: 'btn btn-primary'
|
51
|
+
= link_to t(:cancel), templates_url, class: 'btn'
|
47
52
|
= link_to t(:delete_template), @template, method: :delete, data: {confirm: t(:are_you_sure?)}, class: 'btn btn-danger pull-right' unless @template.new_record?
|
@@ -3,37 +3,18 @@
|
|
3
3
|
|
4
4
|
- content_for :actions do
|
5
5
|
.span4.clearfix.text-right
|
6
|
-
= link_to
|
6
|
+
= link_to new_template_path, class: 'btn btn-link btn-large' do
|
7
|
+
%i.icon-plus
|
8
|
+
=t :new_template
|
7
9
|
|
8
10
|
%section.b-tree.span12
|
9
|
-
|
10
|
-
-
|
11
|
-
- level = root.level
|
12
|
-
- last_template = nil
|
11
|
+
= render_tree(@roots) do |template|
|
12
|
+
%button.btn.btn-link.disabled= template.name
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
<ul>
|
17
|
-
- elsif template.level < level
|
18
|
-
</li>
|
19
|
-
= raw "</ul></li>" * (level-template.level)
|
20
|
-
- elsif !template.root?
|
21
|
-
</li>
|
14
|
+
.b-tree__buttons
|
15
|
+
= render partial: 'constructor_pages/partials/arrow_buttons', locals: {item: template}
|
22
16
|
|
23
|
-
|
24
|
-
%
|
25
|
-
|
26
|
-
.
|
27
|
-
.btn-group
|
28
|
-
- if not template.right_sibling.nil? and template.move_possible?(template.right_sibling)
|
29
|
-
= link_to "<i class='icon-arrow-down'></i>".html_safe, template_move_down_path(template), :method => :post, :class => "btn btn-mini"
|
30
|
-
- if not template.left_sibling.nil? and template.move_possible?(template.left_sibling)
|
31
|
-
= link_to "<i class='icon-arrow-up'></i>".html_safe, template_move_up_path(template), :method => :post, :class => "btn btn-mini"
|
32
|
-
|
33
|
-
= link_to "<i class='icon-pencil'></i> #{t :edit} #{ t(:template).downcase}".html_safe, edit_template_path(template), :class => "btn btn-primary btn-mini"
|
34
|
-
|
35
|
-
|
36
|
-
- level = template.level
|
37
|
-
- last_template = template
|
38
|
-
</li>
|
39
|
-
= raw "</ul></li>" * last_template.level
|
17
|
+
= link_to edit_template_path(template), class: 'btn btn-primary btn-mini' do
|
18
|
+
%i.icon-pencil
|
19
|
+
=t :edit
|
20
|
+
= t(:template).downcase
|
data/pages/config/locales/en.yml
CHANGED
data/pages/config/locales/ru.yml
CHANGED
data/pages/config/routes.rb
CHANGED
@@ -1,32 +1,27 @@
|
|
1
1
|
ConstructorPages::Engine.routes.draw do
|
2
2
|
scope '/admin' do
|
3
|
-
resources :pages, :
|
4
|
-
resources :templates, :
|
5
|
-
resources :fields, :
|
3
|
+
resources :pages, except: [:show]
|
4
|
+
resources :templates, except: [:show]
|
5
|
+
resources :fields, except: [:show, :new, :edit]
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
get 'move/up/:id' => "fields#move_up", :as => :field_move_up
|
12
|
-
get 'move/down/:id' => "fields#move_down", :as => :field_move_down
|
7
|
+
%w{page template field}.each do |c|
|
8
|
+
%w{up down}.each do |d|
|
9
|
+
get "#{c.pluralize}/move/#{d}/:id" => "#{c.pluralize}#move_#{d}", as: "#{c}_move_#{d}"
|
10
|
+
end
|
13
11
|
end
|
14
12
|
|
15
|
-
scope '/
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
get ':page/new' => "pages#new", :as => :new_child_page
|
13
|
+
scope '/fields' do
|
14
|
+
get ':template_id/new/' => 'fields#new', as: :new_field
|
15
|
+
get ':id/:template_id/edit/' => 'fields#edit', as: :edit_field
|
20
16
|
end
|
21
17
|
|
22
|
-
scope '/
|
23
|
-
|
24
|
-
post 'move/down/:id' => "templates#move_down", :as => :template_move_down
|
18
|
+
scope '/pages' do
|
19
|
+
get ':page/new' => 'pages#new', as: :new_child_page
|
25
20
|
end
|
26
21
|
end
|
27
22
|
|
28
|
-
root :to =>
|
29
|
-
get '*all/search/:what_search' =>
|
30
|
-
get '*all.:format' =>
|
31
|
-
get '*all' =>
|
23
|
+
root :to => 'pages#show'
|
24
|
+
get '*all/search/:what_search' => 'pages#search', format: false
|
25
|
+
get '*all.:format' => 'pages#show'
|
26
|
+
get '*all' => 'pages#show'
|
32
27
|
end
|
@@ -0,0 +1,280 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
module ConstructorPages
|
6
|
+
describe 'Pages Controller' do
|
7
|
+
before :all do
|
8
|
+
@user = ConstructorCore::User.create email: 'ivanzotov@gmail.com', password: '123qweASD'
|
9
|
+
@template = Template.create name: 'Page', code_name: 'page'
|
10
|
+
end
|
11
|
+
|
12
|
+
before :each do
|
13
|
+
Page.delete_all
|
14
|
+
Field.delete_all
|
15
|
+
|
16
|
+
Field::TYPES.each do |t|
|
17
|
+
"constructor_pages/types/#{t}_type".classify.constantize.delete_all
|
18
|
+
end
|
19
|
+
|
20
|
+
login_as @user
|
21
|
+
end
|
22
|
+
|
23
|
+
describe 'Index' do
|
24
|
+
context 'Access' do
|
25
|
+
it 'should be accessed by pages_path if loggen in' do
|
26
|
+
visit pages.pages_path
|
27
|
+
current_path.should == pages.pages_path
|
28
|
+
status_code.should == 200
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should not be accessed by pages_path if not loggen in' do
|
32
|
+
logout
|
33
|
+
visit pages.pages_path
|
34
|
+
current_path.should == '/'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should notice if no template exists' do
|
39
|
+
Template.delete_all
|
40
|
+
visit pages.pages_path
|
41
|
+
page.should_not have_link 'New page'
|
42
|
+
page.should have_content 'Create at least one template'
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should not notice if template exists' do
|
46
|
+
visit pages.pages_path
|
47
|
+
page.should have_link 'New page'
|
48
|
+
page.should_not have_text 'Create at least one template'
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should has pages list' do
|
52
|
+
Page.create name: 'Zanussi'
|
53
|
+
visit pages.pages_path
|
54
|
+
page.should have_selector 'ul li'
|
55
|
+
page.should have_link 'Zanussi'
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should has new page link' do
|
59
|
+
visit pages.pages_path
|
60
|
+
page.should have_link 'New page', pages.new_page_path
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should has edit_page link' do
|
64
|
+
_page = Page.create name: 'Zanussi'
|
65
|
+
visit pages.pages_path
|
66
|
+
page.should have_link 'Edit page', pages.edit_page_path(_page)
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should has delete_page link' do
|
70
|
+
_page = Page.create name: 'Zanussi'
|
71
|
+
visit pages.pages_path
|
72
|
+
page.should have_link 'Delete', pages.page_path(_page)
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'should has Add child' do
|
76
|
+
_template = Template.create name: 'Child', code_name: 'child_page', parent: @template
|
77
|
+
_page = Page.create name: 'Zanussi', template: @template
|
78
|
+
visit pages.pages_path
|
79
|
+
page.should have_link 'Add child', pages.new_child_page_path(_page)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe 'Moving' do
|
84
|
+
it 'should move up' do
|
85
|
+
_page_first = Page.create name: 'First'
|
86
|
+
_page_second = Page.create name: 'Second'
|
87
|
+
_page_third = Page.create name: 'Third'
|
88
|
+
|
89
|
+
# test
|
90
|
+
_page_first.lft.should == 1
|
91
|
+
_page_first.rgt.should == 2
|
92
|
+
|
93
|
+
_page_second.lft.should == 3
|
94
|
+
_page_second.rgt.should == 4
|
95
|
+
|
96
|
+
_page_third.lft.should == 5
|
97
|
+
_page_third.rgt.should == 6
|
98
|
+
|
99
|
+
|
100
|
+
# test
|
101
|
+
|
102
|
+
_page_first.left_sibling.should be_nil
|
103
|
+
_page_first.right_sibling.should == _page_second
|
104
|
+
|
105
|
+
_page_second.left_sibling.should == _page_first
|
106
|
+
_page_second.right_sibling.should == _page_third
|
107
|
+
|
108
|
+
_page_third.left_sibling.should == _page_second
|
109
|
+
_page_third.right_sibling.should be_nil
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
describe 'New page' do
|
114
|
+
it 'should be accessed by new_page_path if logged in' do
|
115
|
+
visit pages.new_page_path
|
116
|
+
current_path.should == pages.new_page_path
|
117
|
+
status_code.should == 200
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'should not be accessed by new_page_path if not logged in' do
|
121
|
+
logout
|
122
|
+
visit pages.new_page_path
|
123
|
+
current_path.should == '/'
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'should has child template of parent page' do
|
127
|
+
_template = Template.create name: 'Child', code_name: 'child_page', parent: @template
|
128
|
+
_page = Page.create name: 'Zanussi', template: @template
|
129
|
+
visit pages.pages_path
|
130
|
+
click_link 'Add child'
|
131
|
+
current_path.should == pages.new_child_page_path(_page)
|
132
|
+
page.should have_select 'Template', selected: '-- Child'
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'should has published checkbox' do
|
136
|
+
visit pages.new_page_path
|
137
|
+
page.should have_checked_field 'Active'
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'should has name field' do
|
141
|
+
visit pages.new_page_path
|
142
|
+
page.should have_field 'Name'
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'should has not delete link' do
|
146
|
+
visit pages.new_page_path
|
147
|
+
page.should_not have_link 'Delete'
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'should has create button' do
|
151
|
+
visit pages.new_page_path
|
152
|
+
page.should have_button 'Create Page'
|
153
|
+
end
|
154
|
+
|
155
|
+
it 'should save new page' do
|
156
|
+
visit pages.new_page_path
|
157
|
+
fill_in 'Name', with: 'Hello world'
|
158
|
+
Page.count.should == 0
|
159
|
+
page.click_button 'Create Page'
|
160
|
+
Page.count.should == 1
|
161
|
+
_page = Page.first
|
162
|
+
_page.name.should == 'Hello world'
|
163
|
+
_page.url.should == 'hello-world'
|
164
|
+
current_path.should == pages.pages_path
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
describe 'Edit page' do
|
169
|
+
before :each do
|
170
|
+
@page = Page.create name: 'Hello world'
|
171
|
+
end
|
172
|
+
|
173
|
+
it 'should be accessed by edit_page_path if logged in' do
|
174
|
+
visit pages.edit_page_path(@page)
|
175
|
+
status_code.should == 200
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'should not be accessed by edit_page_path if not logged in' do
|
179
|
+
logout
|
180
|
+
visit pages.edit_page_path(@page)
|
181
|
+
current_path.should == '/'
|
182
|
+
end
|
183
|
+
|
184
|
+
it 'should has delete link' do
|
185
|
+
visit pages.edit_page_path(@page)
|
186
|
+
page.should have_link 'Delete'
|
187
|
+
end
|
188
|
+
|
189
|
+
it 'should edit page' do
|
190
|
+
visit pages.edit_page_path(@page)
|
191
|
+
fill_in 'Name', with: 'Zanussi'
|
192
|
+
fill_in 'Title', with: 'Zanussi conditioners'
|
193
|
+
fill_in 'Keywords', with: 'Zanussi, conditioners, Voronezh'
|
194
|
+
fill_in 'Description', with: 'Zanussi conditioners Voronezh'
|
195
|
+
@page.name.should == 'Hello world'
|
196
|
+
click_button 'Update Page'
|
197
|
+
@page.reload
|
198
|
+
@page.name.should == 'Zanussi'
|
199
|
+
@page.url.should == 'zanussi'
|
200
|
+
@page.title.should == 'Zanussi conditioners'
|
201
|
+
@page.keywords.should == 'Zanussi, conditioners, Voronezh'
|
202
|
+
@page.description.should == 'Zanussi conditioners Voronezh'
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
describe 'Delete page' do
|
207
|
+
it 'should delete from pages index' do
|
208
|
+
Page.create name: 'Page'
|
209
|
+
visit pages.pages_path
|
210
|
+
Page.count.should == 1
|
211
|
+
click_link 'Delete'
|
212
|
+
Page.count.should == 0
|
213
|
+
end
|
214
|
+
|
215
|
+
it 'should delete from page' do
|
216
|
+
_page = Page.create name: 'Page'
|
217
|
+
visit pages.edit_page_path(_page)
|
218
|
+
Page.count.should == 1
|
219
|
+
click_link 'Delete'
|
220
|
+
Page.count.should == 0
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
describe 'Fields' do
|
225
|
+
it 'should create fields after create page' do
|
226
|
+
Field.create name: 'Short description', code_name: 'short_description', template: @template, type_value: 'text'
|
227
|
+
Field.create name: 'Long description', code_name: 'long_description', template: @template, type_value: 'html'
|
228
|
+
|
229
|
+
visit pages.new_page_path
|
230
|
+
fill_in 'Name', with: 'Page'
|
231
|
+
click_button 'Create Page'
|
232
|
+
page.should have_content 'added successfully'
|
233
|
+
|
234
|
+
_page = Page.first
|
235
|
+
_page.short_description.should == ''
|
236
|
+
|
237
|
+
visit pages.edit_page_path(_page)
|
238
|
+
|
239
|
+
fill_in 'Short description', with: 'This is short description'
|
240
|
+
fill_in 'Long description', with: 'This is long description'
|
241
|
+
|
242
|
+
click_button 'Update Page'
|
243
|
+
|
244
|
+
_page.reload
|
245
|
+
_page.short_description.should == 'This is short description'
|
246
|
+
end
|
247
|
+
|
248
|
+
it 'should change fields if template change' do
|
249
|
+
Field.create name: 'Price', code_name: 'price', template: @template, type_value: 'float'
|
250
|
+
_template = Template.create name: 'Brand', code_name: 'brand'
|
251
|
+
Field.create name: 'Amount', code_name: 'amount', template: _template, type_value: 'integer'
|
252
|
+
|
253
|
+
visit pages.new_page_path
|
254
|
+
fill_in 'Name', with: 'Simple page'
|
255
|
+
click_button 'Create Page'
|
256
|
+
_page = Page.first
|
257
|
+
visit pages.edit_page_path(_page)
|
258
|
+
page.should have_selector('#fields_price')
|
259
|
+
fill_in 'Price', with: '250.20'
|
260
|
+
click_button 'Update Page'
|
261
|
+
_page.reload
|
262
|
+
_page.price.should == 250.2
|
263
|
+
visit pages.edit_page_path(_page)
|
264
|
+
select 'Brand', from: 'Template'
|
265
|
+
click_button 'Update Page'
|
266
|
+
_page.reload
|
267
|
+
_page.template.should == _template
|
268
|
+
_page.price.should be_nil
|
269
|
+
_page.amount.should == 0
|
270
|
+
visit pages.edit_page_path(_page)
|
271
|
+
page.should_not have_selector('#fields_price')
|
272
|
+
page.should have_selector('#fields_amount')
|
273
|
+
fill_in 'Amount', with: 200
|
274
|
+
click_button 'Update Page'
|
275
|
+
_page.reload
|
276
|
+
_page.amount.should == 200
|
277
|
+
end
|
278
|
+
end
|
279
|
+
end
|
280
|
+
end
|