constructor-cms 0.6.3 → 0.6.4
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/core/lib/constructor_core/version.rb +1 -1
- data/pages/app/{helpers/constructor_pages/move_helper.rb → controllers/constructor_pages/application_controller.rb} +8 -2
- data/pages/app/controllers/constructor_pages/fields_controller.rb +1 -1
- data/pages/app/controllers/constructor_pages/pages_controller.rb +4 -6
- data/pages/app/controllers/constructor_pages/templates_controller.rb +11 -7
- data/pages/app/models/constructor_pages/field.rb +1 -1
- data/pages/app/models/constructor_pages/page.rb +1 -4
- data/pages/app/models/constructor_pages/template.rb +2 -2
- data/pages/app/views/constructor_pages/pages/_form.haml +5 -4
- data/pages/app/views/constructor_pages/templates/_form.haml +7 -6
- data/pages/app/views/constructor_pages/templates/index.haml +5 -1
- data/pages/config/locales/en.yml +11 -1
- data/pages/config/locales/ru.yml +9 -2
- data/pages/spec/features/constructor_pages/pages_controller_spec.rb +64 -34
- data/pages/spec/features/constructor_pages/templates_controller_spec.rb +263 -0
- data/pages/spec/models/constructor_pages/field_model_spec.rb +0 -3
- data/pages/spec/models/constructor_pages/page_model_spec.rb +8 -0
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 022e7812dfa74494097fba1ab00b54dee5c175c7
|
4
|
+
data.tar.gz: 301e5215f6a22164105e95d8d2b9039b7222595b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1afc9d110882f7e27d319d8949365f3132f092442ce1d882c57f1b613829f02cd674a75c434ba5c71bf184984309aaec18726859f874486cfbbb70a8a0f21c0
|
7
|
+
data.tar.gz: b959c494f45c7c837fec8dae249464151b1559af23025df3778e06493b5315670123cadab991375244b8c3511005b0da03d1e82c2a18094708c3ab8231ec5fd6
|
@@ -1,5 +1,11 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
module ConstructorPages
|
2
|
-
|
4
|
+
class ApplicationController < ConstructorCore::ApplicationController
|
5
|
+
def self.movable(what)
|
6
|
+
%w{up down}.each {|m| define_method "move_#{m}" do move_to what, params[:id], m.to_sym end}
|
7
|
+
end
|
8
|
+
|
3
9
|
def move_to(what, id, to)
|
4
10
|
from = ('constructor_pages/'+what.to_s).classify.constantize.find(id)
|
5
11
|
to_sibling = to == :up ? from.left_sibling : from.right_sibling
|
@@ -11,4 +17,4 @@ module ConstructorPages
|
|
11
17
|
redirect_to :back
|
12
18
|
end
|
13
19
|
end
|
14
|
-
end
|
20
|
+
end
|
@@ -1,17 +1,17 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
module ConstructorPages
|
4
|
-
class PagesController <
|
5
|
-
|
4
|
+
class PagesController < ApplicationController
|
5
|
+
movable :page
|
6
6
|
|
7
|
-
before_filter {@roots = Page.roots}
|
7
|
+
before_filter {@roots, @template_exists = Page.roots, Template.count > 0}
|
8
8
|
|
9
9
|
def index
|
10
|
-
@template_exists = Template.count > 0
|
11
10
|
flash.notice = 'Create at least one template' unless @template_exists
|
12
11
|
end
|
13
12
|
|
14
13
|
def new
|
14
|
+
redirect_to pages_path and return unless @template_exists
|
15
15
|
@page, @template_id, @multipart = Page.new, Template.first.id, false
|
16
16
|
|
17
17
|
if params[:page] and (@page.parent = Page.find(params[:page]))
|
@@ -128,8 +128,6 @@ module ConstructorPages
|
|
128
128
|
redirect_to pages_url, notice: t(:page_success_removed, name: _name)
|
129
129
|
end
|
130
130
|
|
131
|
-
%w{up down}.each {|m| define_method "move_#{m}" do move_to :page, params[:id], m.to_sym end}
|
132
|
-
|
133
131
|
private
|
134
132
|
|
135
133
|
def page_params
|
@@ -1,10 +1,11 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
module ConstructorPages
|
4
|
-
class TemplatesController <
|
5
|
-
include MoveHelper
|
4
|
+
class TemplatesController < ApplicationController
|
6
5
|
include TreeviewHelper
|
7
6
|
|
7
|
+
movable :template
|
8
|
+
|
8
9
|
before_filter {@roots = Template.roots}
|
9
10
|
|
10
11
|
def new
|
@@ -37,12 +38,15 @@ module ConstructorPages
|
|
37
38
|
|
38
39
|
def destroy
|
39
40
|
@template = Template.find(params[:id])
|
40
|
-
name = @template.name
|
41
|
-
@template.destroy
|
42
|
-
redirect_to templates_url, notice: t(:template_success_removed, name: name)
|
43
|
-
end
|
44
41
|
|
45
|
-
|
42
|
+
if @template.pages.count == 0
|
43
|
+
name = @template.name
|
44
|
+
@template.destroy
|
45
|
+
redirect_to templates_url, notice: t(:template_success_removed, name: name)
|
46
|
+
else
|
47
|
+
redirect_to :back, alert: t(:template_error_delete_pages)
|
48
|
+
end
|
49
|
+
end
|
46
50
|
|
47
51
|
private
|
48
52
|
|
@@ -23,7 +23,7 @@ module ConstructorPages
|
|
23
23
|
# Adding has_many for all field types
|
24
24
|
TYPES.each do |t|
|
25
25
|
class_eval %{
|
26
|
-
has_many :#{t}_types, class_name: 'Types::#{t.titleize}Type'
|
26
|
+
has_many :#{t}_types, dependent: :destroy, class_name: 'Types::#{t.titleize}Type'
|
27
27
|
}
|
28
28
|
end
|
29
29
|
|
@@ -42,10 +42,7 @@ module ConstructorPages
|
|
42
42
|
# field and template code_name should be uniqueness for page methods
|
43
43
|
def self.check_code_name(code_name)
|
44
44
|
[code_name, code_name.pluralize, code_name.singularize].each do |name|
|
45
|
-
|
46
|
-
if Page.first.respond_to?(name)
|
47
|
-
return false
|
48
|
-
end
|
45
|
+
return false if Page.instance_methods.include?(name.to_sym)
|
49
46
|
end
|
50
47
|
|
51
48
|
true
|
@@ -1,9 +1,10 @@
|
|
1
1
|
= form_for @page, html: {multipart: @multipart} do |f|
|
2
2
|
- if @page.errors.any?
|
3
|
-
.
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
.row-fluid
|
4
|
+
.alert.alert-error.fade.in.span12
|
5
|
+
= link_to '×', '#', class: 'close', 'data-dismiss' => 'alert'
|
6
|
+
- @page.errors.full_messages.each do |m|
|
7
|
+
= m
|
7
8
|
|
8
9
|
.form-horizontal
|
9
10
|
.control-group
|
@@ -1,9 +1,10 @@
|
|
1
1
|
= form_for @template do |f|
|
2
2
|
- if @template.errors.any?
|
3
|
-
.
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
.row-fluid
|
4
|
+
.alert.alert-error.fade.in.span12
|
5
|
+
= link_to '×', '#', class: 'close', 'data-dismiss' => 'alert'
|
6
|
+
- @template.errors.full_messages.each do |m|
|
7
|
+
= m
|
7
8
|
|
8
9
|
.form-horizontal
|
9
10
|
.control-group
|
@@ -15,12 +16,12 @@
|
|
15
16
|
.controls= f.text_field :code_name, class: 'span4'
|
16
17
|
|
17
18
|
.control-group
|
18
|
-
= f.label :
|
19
|
+
= f.label :parent_id, class: 'control-label'
|
19
20
|
.controls
|
20
21
|
= 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
22
|
|
22
23
|
.control-group
|
23
|
-
= f.label :
|
24
|
+
= f.label :child_id, class: 'control-label'
|
24
25
|
.controls
|
25
26
|
= f.select :child_id, options_for_select(for_select(@roots), selected: @template.child_id), include_blank: t(:no)
|
26
27
|
|
@@ -17,4 +17,8 @@
|
|
17
17
|
= link_to edit_template_path(template), class: 'btn btn-primary btn-mini' do
|
18
18
|
%i.icon-pencil
|
19
19
|
=t :edit
|
20
|
-
= t(:template).downcase
|
20
|
+
= t(:template).downcase
|
21
|
+
|
22
|
+
= link_to template_path(template), method: :delete, class: 'btn btn-danger btn-mini pull-right', data: {confirm: t(:are_you_sure?)} do
|
23
|
+
%i.icon-remove
|
24
|
+
=t :delete
|
data/pages/config/locales/en.yml
CHANGED
@@ -49,4 +49,14 @@ en:
|
|
49
49
|
|
50
50
|
template_success_added: 'Template «%{name}» added successfully.'
|
51
51
|
template_success_updated: 'Template «%{name}» updated successfully.'
|
52
|
-
template_success_removed: 'Template «%{name}» removed successfully.'
|
52
|
+
template_success_removed: 'Template «%{name}» removed successfully.'
|
53
|
+
|
54
|
+
template_error_delete_pages: 'Delete pages with this template before'
|
55
|
+
|
56
|
+
activerecord:
|
57
|
+
errors:
|
58
|
+
models:
|
59
|
+
constructor_pages/template:
|
60
|
+
attributes:
|
61
|
+
base:
|
62
|
+
code_name_already_in_use: 'Code name has already been taken'
|
data/pages/config/locales/ru.yml
CHANGED
@@ -11,7 +11,7 @@ ru:
|
|
11
11
|
|
12
12
|
menu: 'Меню'
|
13
13
|
breadcrumbs: 'Хлебные крошки'
|
14
|
-
|
14
|
+
code_name_already_in_use: 'Такое кодовое имя уже используется'
|
15
15
|
template: 'Шаблон'
|
16
16
|
new_template: 'Создать шаблон'
|
17
17
|
edit_template: 'Редактирование шаблона'
|
@@ -49,6 +49,8 @@ ru:
|
|
49
49
|
template_success_updated: 'Шаблон «%{name}» успешно обновлен.'
|
50
50
|
template_success_removed: 'Шаблон «%{name}» успешно удален.'
|
51
51
|
|
52
|
+
template_error_delete_pages: 'Удалите страницы с данным шаблоном'
|
53
|
+
|
52
54
|
activerecord:
|
53
55
|
attributes:
|
54
56
|
constructor_pages/field:
|
@@ -60,6 +62,7 @@ ru:
|
|
60
62
|
code_name: "Кодовое имя"
|
61
63
|
parent: "Родительский"
|
62
64
|
child: "Дочерний"
|
65
|
+
|
63
66
|
constructor_pages/page:
|
64
67
|
active: "Вкл./Выкл."
|
65
68
|
image: "Изображение"
|
@@ -86,4 +89,8 @@ ru:
|
|
86
89
|
title:
|
87
90
|
blank: "не может быть пустым"
|
88
91
|
url:
|
89
|
-
blank: "не может быть пустой"
|
92
|
+
blank: "не может быть пустой"
|
93
|
+
constructor_pages/template:
|
94
|
+
attributes:
|
95
|
+
base:
|
96
|
+
code_name_already_in_use: 'Такое кодовое имя уже используется'
|
@@ -5,18 +5,21 @@ require 'spec_helper'
|
|
5
5
|
module ConstructorPages
|
6
6
|
describe 'Pages Controller' do
|
7
7
|
before :all do
|
8
|
+
ConstructorCore::User.delete_all
|
8
9
|
@user = ConstructorCore::User.create email: 'ivanzotov@gmail.com', password: '123qweASD'
|
9
|
-
@template = Template.create name: 'Page', code_name: 'page'
|
10
10
|
end
|
11
11
|
|
12
12
|
before :each do
|
13
13
|
Page.delete_all
|
14
14
|
Field.delete_all
|
15
|
+
Template.delete_all
|
15
16
|
|
16
17
|
Field::TYPES.each do |t|
|
17
18
|
"constructor_pages/types/#{t}_type".classify.constantize.delete_all
|
18
19
|
end
|
19
20
|
|
21
|
+
@template = Template.create name: 'Page', code_name: 'page'
|
22
|
+
|
20
23
|
login_as @user
|
21
24
|
end
|
22
25
|
|
@@ -72,7 +75,7 @@ module ConstructorPages
|
|
72
75
|
page.should have_link 'Delete', pages.page_path(_page)
|
73
76
|
end
|
74
77
|
|
75
|
-
it 'should has Add child' do
|
78
|
+
it 'should has Add child if child exists' do
|
76
79
|
_template = Template.create name: 'Child', code_name: 'child_page', parent: @template
|
77
80
|
_page = Page.create name: 'Zanussi', template: @template
|
78
81
|
visit pages.pages_path
|
@@ -81,46 +84,64 @@ module ConstructorPages
|
|
81
84
|
end
|
82
85
|
|
83
86
|
describe 'Moving' do
|
84
|
-
it 'should move
|
87
|
+
it 'should move page' do
|
85
88
|
_page_first = Page.create name: 'First'
|
86
89
|
_page_second = Page.create name: 'Second'
|
87
90
|
_page_third = Page.create name: 'Third'
|
88
91
|
|
89
|
-
|
90
|
-
_page_first.
|
91
|
-
|
92
|
+
_page_first.left_sibling.should be_nil
|
93
|
+
_page_first.right_sibling.should == _page_second
|
94
|
+
|
95
|
+
_page_second.left_sibling.should == _page_first
|
96
|
+
_page_second.right_sibling.should == _page_third
|
97
|
+
|
98
|
+
_page_third.left_sibling.should == _page_second
|
99
|
+
_page_third.right_sibling.should be_nil
|
100
|
+
|
101
|
+
visit pages.pages_path
|
102
|
+
find("a[href='#{pages.page_move_down_path(_page_first.id)}']").click
|
92
103
|
|
93
|
-
|
94
|
-
|
104
|
+
_page_first.reload
|
105
|
+
_page_first.left_sibling.should == _page_second
|
106
|
+
_page_first.right_sibling.should == _page_third
|
95
107
|
|
96
|
-
|
97
|
-
|
108
|
+
_page_second.reload
|
109
|
+
_page_second.left_sibling.should be_nil
|
110
|
+
_page_second.right_sibling.should == _page_first
|
98
111
|
|
112
|
+
_page_third.reload
|
113
|
+
_page_third.left_sibling.should == _page_first
|
114
|
+
_page_third.right_sibling.should be_nil
|
99
115
|
|
100
|
-
#
|
116
|
+
find("a[href='#{pages.page_move_up_path(_page_third.id)}']").click
|
101
117
|
|
102
|
-
_page_first.
|
103
|
-
_page_first.
|
118
|
+
_page_first.reload
|
119
|
+
_page_first.left_sibling.should == _page_third
|
120
|
+
_page_first.right_sibling.should be_nil
|
104
121
|
|
105
|
-
_page_second.
|
122
|
+
_page_second.reload
|
123
|
+
_page_second.left_sibling.should be_nil
|
106
124
|
_page_second.right_sibling.should == _page_third
|
107
125
|
|
126
|
+
_page_third.reload
|
108
127
|
_page_third.left_sibling.should == _page_second
|
109
|
-
_page_third.right_sibling.should
|
128
|
+
_page_third.right_sibling.should == _page_first
|
110
129
|
end
|
111
130
|
end
|
112
131
|
|
113
132
|
describe 'New page' do
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
133
|
+
describe 'Access' do
|
134
|
+
it 'should be accessed by new_page_path if logged in' do
|
135
|
+
visit pages.new_page_path
|
136
|
+
current_path.should == pages.new_page_path
|
137
|
+
status_code.should == 200
|
138
|
+
end
|
119
139
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
140
|
+
it 'should not be accessed by new_page_path if not logged in' do
|
141
|
+
logout
|
142
|
+
visit pages.new_page_path
|
143
|
+
current_path.should == '/'
|
144
|
+
end
|
124
145
|
end
|
125
146
|
|
126
147
|
it 'should has child template of parent page' do
|
@@ -142,7 +163,7 @@ module ConstructorPages
|
|
142
163
|
page.should have_field 'Name'
|
143
164
|
end
|
144
165
|
|
145
|
-
it 'should has
|
166
|
+
it 'should has no delete link' do
|
146
167
|
visit pages.new_page_path
|
147
168
|
page.should_not have_link 'Delete'
|
148
169
|
end
|
@@ -156,13 +177,20 @@ module ConstructorPages
|
|
156
177
|
visit pages.new_page_path
|
157
178
|
fill_in 'Name', with: 'Hello world'
|
158
179
|
Page.count.should == 0
|
159
|
-
|
180
|
+
click_button 'Create Page'
|
160
181
|
Page.count.should == 1
|
161
182
|
_page = Page.first
|
162
183
|
_page.name.should == 'Hello world'
|
163
184
|
_page.url.should == 'hello-world'
|
164
185
|
current_path.should == pages.pages_path
|
165
186
|
end
|
187
|
+
|
188
|
+
it 'should redirect to back if no template exists' do
|
189
|
+
Template.delete_all
|
190
|
+
visit pages.new_page_path
|
191
|
+
current_path.should == pages.pages_path
|
192
|
+
page.should have_text 'Create at least one template'
|
193
|
+
end
|
166
194
|
end
|
167
195
|
|
168
196
|
describe 'Edit page' do
|
@@ -170,15 +198,17 @@ module ConstructorPages
|
|
170
198
|
@page = Page.create name: 'Hello world'
|
171
199
|
end
|
172
200
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
201
|
+
describe 'Access' do
|
202
|
+
it 'should be accessed by edit_page_path if logged in' do
|
203
|
+
visit pages.edit_page_path(@page)
|
204
|
+
status_code.should == 200
|
205
|
+
end
|
177
206
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
207
|
+
it 'should not be accessed by edit_page_path if not logged in' do
|
208
|
+
logout
|
209
|
+
visit pages.edit_page_path(@page)
|
210
|
+
current_path.should == '/'
|
211
|
+
end
|
182
212
|
end
|
183
213
|
|
184
214
|
it 'should has delete link' do
|
@@ -0,0 +1,263 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
module ConstructorPages
|
6
|
+
describe 'Templates Controller' do
|
7
|
+
before :all do
|
8
|
+
ConstructorCore::User.delete_all
|
9
|
+
@user = ConstructorCore::User.create email: 'ivanzotov@gmail.com', password: '123qweASD'
|
10
|
+
end
|
11
|
+
|
12
|
+
before :each do
|
13
|
+
Page.delete_all
|
14
|
+
Field.delete_all
|
15
|
+
Template.delete_all
|
16
|
+
|
17
|
+
Field::TYPES.each do |t|
|
18
|
+
"constructor_pages/types/#{t}_type".classify.constantize.delete_all
|
19
|
+
end
|
20
|
+
|
21
|
+
login_as @user
|
22
|
+
end
|
23
|
+
|
24
|
+
describe 'Index' do
|
25
|
+
describe 'Access' do
|
26
|
+
it 'should be accessed by pages.templates_path if logged in' do
|
27
|
+
visit pages.templates_path
|
28
|
+
current_path.should == pages.templates_path
|
29
|
+
status_code.should == 200
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should not be accessed by pages.templates_path if not logged in' do
|
33
|
+
logout
|
34
|
+
visit pages.templates_path
|
35
|
+
current_path.should == '/'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should has new template link' do
|
40
|
+
visit pages.templates_path
|
41
|
+
page.should have_link 'New template', pages.new_template_path
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should has list of templates' do
|
45
|
+
Template.create name: 'Page', code_name: 'page'
|
46
|
+
visit pages.templates_path
|
47
|
+
page.should have_selector 'ul li'
|
48
|
+
page.should have_text 'Page'
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should has edit_template link' do
|
52
|
+
_template = Template.create name: 'Page', code_name: 'page'
|
53
|
+
visit pages.templates_path
|
54
|
+
page.should have_link 'Edit template', pages.edit_template_path(_template)
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should has delete_page link' do
|
58
|
+
_template = Template.create name: 'Page', code_name: 'page'
|
59
|
+
visit pages.templates_path
|
60
|
+
page.should have_link 'Delete', pages.template_path(_template)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe 'Moving' do
|
65
|
+
it 'should move template' do
|
66
|
+
_template_first = Template.create name: 'First', code_name: 'first'
|
67
|
+
_template_second = Template.create name: 'Second', code_name: 'second'
|
68
|
+
_template_third = Template.create name: 'Third', code_name: 'third'
|
69
|
+
|
70
|
+
_template_first.left_sibling.should be_nil
|
71
|
+
_template_first.right_sibling.should == _template_second
|
72
|
+
|
73
|
+
_template_second.left_sibling.should == _template_first
|
74
|
+
_template_second.right_sibling.should == _template_third
|
75
|
+
|
76
|
+
_template_third.left_sibling.should == _template_second
|
77
|
+
_template_third.right_sibling.should be_nil
|
78
|
+
|
79
|
+
visit pages.templates_path
|
80
|
+
|
81
|
+
find("a[href='#{pages.template_move_down_path(_template_first.id)}']").click
|
82
|
+
|
83
|
+
_template_first.reload
|
84
|
+
_template_first.left_sibling.should == _template_second
|
85
|
+
_template_first.right_sibling.should == _template_third
|
86
|
+
|
87
|
+
_template_second.reload
|
88
|
+
_template_second.left_sibling.should be_nil
|
89
|
+
_template_second.right_sibling.should == _template_first
|
90
|
+
|
91
|
+
_template_third.reload
|
92
|
+
_template_third.left_sibling.should == _template_first
|
93
|
+
_template_third.right_sibling.should be_nil
|
94
|
+
|
95
|
+
find("a[href='#{pages.template_move_up_path(_template_third.id)}']").click
|
96
|
+
|
97
|
+
_template_first.reload
|
98
|
+
_template_first.left_sibling.should == _template_third
|
99
|
+
_template_first.right_sibling.should be_nil
|
100
|
+
|
101
|
+
_template_second.reload
|
102
|
+
_template_second.left_sibling.should be_nil
|
103
|
+
_template_second.right_sibling.should == _template_third
|
104
|
+
|
105
|
+
_template_third.reload
|
106
|
+
_template_third.left_sibling.should == _template_second
|
107
|
+
_template_third.right_sibling.should == _template_first
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe 'New template' do
|
112
|
+
describe 'Access' do
|
113
|
+
it 'should be accessed by new_template_path if logged in' do
|
114
|
+
visit pages.new_template_path
|
115
|
+
current_path.should == pages.new_template_path
|
116
|
+
status_code.should == 200
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'should not be accessed by new_template_path if not logged in' do
|
120
|
+
logout
|
121
|
+
visit pages.new_template_path
|
122
|
+
current_path.should == '/'
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'should has name field' do
|
127
|
+
visit pages.new_template_path
|
128
|
+
page.should have_field 'Name'
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'should has code_name field' do
|
132
|
+
visit pages.new_template_path
|
133
|
+
page.should have_field 'Code name'
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'should has parent and child selects' do
|
137
|
+
visit pages.new_template_path
|
138
|
+
page.should have_select 'Parent'
|
139
|
+
page.should have_select 'Child'
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'should not has link new field' do
|
143
|
+
visit pages.new_template_path
|
144
|
+
page.should_not have_link 'New field'
|
145
|
+
end
|
146
|
+
|
147
|
+
it 'should not has delete link' do
|
148
|
+
visit pages.new_template_path
|
149
|
+
page.should_not have_link 'Delete template'
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'should has Create Template button' do
|
153
|
+
visit pages.new_template_path
|
154
|
+
page.should have_button 'Create Template'
|
155
|
+
end
|
156
|
+
|
157
|
+
it 'should create new template' do
|
158
|
+
visit pages.new_template_path
|
159
|
+
fill_in 'Name', with: 'Brand'
|
160
|
+
fill_in 'Code name', with: 'brand'
|
161
|
+
Template.count.should == 0
|
162
|
+
click_button 'Create Template'
|
163
|
+
current_path.should == pages.templates_path
|
164
|
+
Template.count.should == 1
|
165
|
+
_template = Template.first
|
166
|
+
_template.name.should == 'Brand'
|
167
|
+
_template.code_name.should == 'brand'
|
168
|
+
end
|
169
|
+
|
170
|
+
it 'should validate uniqueness of code name' do
|
171
|
+
Template.create name: 'Brand', code_name: 'brand'
|
172
|
+
visit pages.new_template_path
|
173
|
+
fill_in 'Name', with: 'Brand'
|
174
|
+
fill_in 'Code name', with: 'brand'
|
175
|
+
click_button 'Create Template'
|
176
|
+
current_path.should == pages.templates_path
|
177
|
+
page.should have_text 'Code name has already been taken'
|
178
|
+
end
|
179
|
+
|
180
|
+
it 'should validate uniqueness of code name with Page' do
|
181
|
+
visit pages.new_template_path
|
182
|
+
fill_in 'Name', with: 'Brand'
|
183
|
+
fill_in 'Code name', with: 'get_field_value'
|
184
|
+
Template.count.should == 0
|
185
|
+
click_button 'Create Template'
|
186
|
+
Template.count.should == 0
|
187
|
+
page.should have_text 'Code name has already been taken'
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
describe 'Edit template' do
|
192
|
+
before :each do
|
193
|
+
@template = Template.create name: 'Page', code_name: 'page'
|
194
|
+
end
|
195
|
+
|
196
|
+
describe 'Access' do
|
197
|
+
it 'should be accessed by edit_template_path if logged in' do
|
198
|
+
visit pages.edit_template_path(@template)
|
199
|
+
status_code.should == 200
|
200
|
+
end
|
201
|
+
|
202
|
+
it 'should not be accessed by edit_template_path if not logged in' do
|
203
|
+
logout
|
204
|
+
visit pages.edit_template_path(@template)
|
205
|
+
current_path.should == '/'
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
it 'should has delete link' do
|
210
|
+
visit pages.edit_template_path(@template)
|
211
|
+
page.should have_link 'Delete template'
|
212
|
+
end
|
213
|
+
|
214
|
+
it 'should has new field link' do
|
215
|
+
visit pages.edit_template_path(@template)
|
216
|
+
page.should have_link 'New field', pages.new_field_path(@template)
|
217
|
+
end
|
218
|
+
|
219
|
+
it 'should has update template button' do
|
220
|
+
visit pages.edit_template_path(@template)
|
221
|
+
page.should have_button 'Update Template'
|
222
|
+
end
|
223
|
+
|
224
|
+
it 'should edit template' do
|
225
|
+
visit pages.edit_template_path(@template)
|
226
|
+
fill_in 'Name', with: 'New brand'
|
227
|
+
fill_in 'Code name', with: 'new_brand'
|
228
|
+
click_button 'Update Template'
|
229
|
+
@template.reload
|
230
|
+
@template.name.should == 'New brand'
|
231
|
+
@template.code_name.should == 'new_brand'
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
describe 'Delete template' do
|
236
|
+
it 'should delete from templates index' do
|
237
|
+
Template.create name: 'Page', code_name: 'page'
|
238
|
+
visit pages.templates_path
|
239
|
+
Template.count.should == 1
|
240
|
+
click_link 'Delete'
|
241
|
+
Template.count.should == 0
|
242
|
+
end
|
243
|
+
|
244
|
+
it 'should delete from template' do
|
245
|
+
_template = Template.create name: 'Page', code_name: 'page'
|
246
|
+
visit pages.edit_template_path(_template)
|
247
|
+
Template.count.should == 1
|
248
|
+
click_link 'Delete'
|
249
|
+
Template.count.should == 0
|
250
|
+
end
|
251
|
+
|
252
|
+
it 'should not delete if there are any pages' do
|
253
|
+
_template = Template.create name: 'Page', code_name: 'page'
|
254
|
+
Page.create name: 'Home page', template: _template
|
255
|
+
visit pages.edit_template_path(_template)
|
256
|
+
Template.count.should == 1
|
257
|
+
click_link 'Delete'
|
258
|
+
Template.count.should == 1
|
259
|
+
page.should have_text 'Delete pages with this template before'
|
260
|
+
end
|
261
|
+
end
|
262
|
+
end
|
263
|
+
end
|
@@ -113,14 +113,11 @@ module ConstructorPages
|
|
113
113
|
end
|
114
114
|
|
115
115
|
it 'should be uniqueness in scope Page' do
|
116
|
-
Page.create name: 'Page', template: @template
|
117
116
|
_field = Field.create name: 'Content', code_name: 'get_field_value', template: @template, type_value: 'text'
|
118
117
|
_field.should_not be_valid
|
119
118
|
end
|
120
119
|
|
121
120
|
it 'should be uniqueness in scope Template branch' do
|
122
|
-
Page.create name: 'Page', template: @template
|
123
|
-
|
124
121
|
_template = Template.create name: 'Brand', code_name: 'brand', parent: @template
|
125
122
|
@template.reload
|
126
123
|
|
@@ -49,6 +49,14 @@ module ConstructorPages
|
|
49
49
|
Page.full_url_generate(second_page.id, 'third-page').should == '/first-page/second-page/third-page'
|
50
50
|
end
|
51
51
|
end
|
52
|
+
|
53
|
+
describe '.check_code_name' do
|
54
|
+
it 'should check existing code_name in instance_methods' do
|
55
|
+
Page.check_code_name('get_field_value').should be_false
|
56
|
+
Page.check_code_name('class').should be_false
|
57
|
+
Page.check_code_name('hello_world').should be_true
|
58
|
+
end
|
59
|
+
end
|
52
60
|
end
|
53
61
|
|
54
62
|
context 'INSTANCE METHODS' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: constructor-cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Zotov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: constructor-core
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.6.
|
19
|
+
version: 0.6.4
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.6.
|
26
|
+
version: 0.6.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: constructor-pages
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.6.
|
33
|
+
version: 0.6.4
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.6.
|
40
|
+
version: 0.6.4
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: sqlite3
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -341,12 +341,12 @@ files:
|
|
341
341
|
- pages/app/assets/images/constructor_pages/photos.png
|
342
342
|
- pages/app/assets/javascripts/constructor_pages/ajax_pages.js
|
343
343
|
- pages/app/assets/javascripts/constructor_pages/jquery.history.js
|
344
|
+
- pages/app/controllers/constructor_pages/application_controller.rb
|
344
345
|
- pages/app/controllers/constructor_pages/fields_controller.rb
|
345
346
|
- pages/app/controllers/constructor_pages/pages_controller.rb
|
346
347
|
- pages/app/controllers/constructor_pages/templates_controller.rb
|
347
348
|
- pages/app/helpers/constructor_pages/code_name_uniq.rb
|
348
349
|
- pages/app/helpers/constructor_pages/fields_helper.rb
|
349
|
-
- pages/app/helpers/constructor_pages/move_helper.rb
|
350
350
|
- pages/app/helpers/constructor_pages/pages_helper.rb
|
351
351
|
- pages/app/helpers/constructor_pages/templates_helper.rb
|
352
352
|
- pages/app/helpers/constructor_pages/treeview_helper.rb
|
@@ -406,6 +406,7 @@ files:
|
|
406
406
|
- pages/lib/constructor_pages/engine.rb
|
407
407
|
- pages/public/hello.txt
|
408
408
|
- pages/spec/features/constructor_pages/pages_controller_spec.rb
|
409
|
+
- pages/spec/features/constructor_pages/templates_controller_spec.rb
|
409
410
|
- pages/spec/models/constructor_pages/field_model_spec.rb
|
410
411
|
- pages/spec/models/constructor_pages/page_model_spec.rb
|
411
412
|
- pages/spec/models/constructor_pages/template_model_spec.rb
|