chr 0.3.5 → 0.4.9
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/.coveralls.yml +2 -0
- data/.gitignore +6 -1
- data/.ruby-version +1 -0
- data/.travis.yml +18 -0
- data/README.md +4 -0
- data/Rakefile +17 -2
- data/app/assets/javascripts/chr.coffee +13 -26
- data/app/assets/javascripts/chr/{core/chr.coffee → chr.coffee} +4 -1
- data/app/assets/javascripts/chr/{core/chr_router.coffee → chr_router.coffee} +0 -0
- data/app/assets/javascripts/chr/{core/item.coffee → item.coffee} +2 -1
- data/app/assets/javascripts/chr/{core/list.coffee → list.coffee} +1 -1
- data/app/assets/javascripts/chr/{core/list_config.coffee → list_config.coffee} +0 -0
- data/app/assets/javascripts/chr/{core/list_pagination.coffee → list_pagination.coffee} +15 -4
- data/app/assets/javascripts/chr/{core/list_reorder.coffee → list_reorder.coffee} +0 -0
- data/app/assets/javascripts/chr/{core/list_search.coffee → list_search.coffee} +1 -1
- data/app/assets/javascripts/chr/{core/module.coffee → module.coffee} +0 -0
- data/app/assets/javascripts/chr/{core/utils.coffee → utils.coffee} +0 -0
- data/app/assets/javascripts/chr/{core/view.coffee → view.coffee} +21 -9
- data/app/assets/javascripts/chr/{core/view_local-storage.coffee → view_local-storage.coffee} +0 -0
- data/app/assets/javascripts/{chr/store/array-store.coffee → stores/array.coffee} +0 -0
- data/app/assets/javascripts/{chr/store/object-store.coffee → stores/object.coffee} +0 -0
- data/app/assets/javascripts/{chr/store/rails-array-store.coffee → stores/rails-array.coffee} +0 -0
- data/app/assets/javascripts/{chr/store → stores}/rails-form-object-parser.coffee +4 -1
- data/app/assets/javascripts/{chr/store/rails-object-store.coffee → stores/rails-object.coffee} +0 -0
- data/app/assets/javascripts/{chr/store/rest-array-store.coffee → stores/rest-array.coffee} +5 -2
- data/app/assets/javascripts/{chr/store/rest-object-store.coffee → stores/rest-object.coffee} +0 -0
- data/app/assets/stylesheets/{_chr.scss → chr.scss} +2 -7
- data/app/assets/stylesheets/chr/{_icons.scss → icons.scss} +0 -0
- data/app/assets/stylesheets/chr/{_main.scss → main.scss} +10 -3
- data/app/assets/stylesheets/chr/{_mixins.scss → mixins.scss} +0 -77
- data/app/assets/stylesheets/chr/{_settings.scss → settings.scss} +1 -1
- data/bin/chr +13 -0
- data/bin/rake +16 -0
- data/bin/setup +13 -0
- data/chr.gemspec +41 -21
- data/docs/tests.md +64 -0
- data/lib/chr.rb +10 -2
- data/lib/chr/app_builder.rb +385 -0
- data/lib/chr/generators/app_generator.rb +213 -0
- data/lib/chr/version.rb +3 -1
- data/lib/generators/chr/controller_generator.rb +18 -0
- data/templates/Gemfile.erb +38 -0
- data/templates/Procfile +1 -0
- data/templates/README.md.erb +45 -0
- data/templates/_analytics.html.erb +9 -0
- data/templates/_flashes.html.erb +7 -0
- data/templates/_javascript.html.erb +12 -0
- data/templates/application.coffee +2 -0
- data/templates/application.scss +1 -0
- data/templates/application.yml +6 -0
- data/templates/application_gitignore +14 -0
- data/templates/application_layout.html.erb.erb +29 -0
- data/templates/asset_sync.rb +28 -0
- data/templates/bin_setup.erb +36 -0
- data/templates/body_class_helper.rb +19 -0
- data/templates/bundler_audit.rake +12 -0
- data/templates/carrierwave.rb +23 -0
- data/templates/character_admin.coffee.erb +28 -0
- data/templates/character_admin.scss +3 -0
- data/templates/character_admin_index.html.erb +2 -0
- data/templates/character_admin_layout.html.erb +21 -0
- data/templates/character_base_controller.rb +16 -0
- data/templates/development_seeds.rb +12 -0
- data/templates/devise_overrides_passwords_controller.rb +10 -0
- data/templates/devise_overrides_passwords_edit.html.erb +30 -0
- data/templates/devise_overrides_passwords_new.html.erb +21 -0
- data/templates/devise_overrides_sessions_controller.rb +12 -0
- data/templates/devise_overrides_sessions_new.html.erb +31 -0
- data/templates/errors.rb +34 -0
- data/templates/json_encoding.rb +1 -0
- data/templates/newrelic.yml.erb +34 -0
- data/templates/puma.rb +18 -0
- data/templates/routes.rb +90 -0
- data/templates/sample.env +6 -0
- data/templates/secrets.yml +14 -0
- data/templates/smtp.rb +9 -0
- data/templates/staging.rb +5 -0
- data/test/factories/article_factory.rb +19 -0
- data/test/files/test.jpg +0 -0
- data/test/integration/article_fullsize_test.rb +33 -0
- data/test/integration/article_test.rb +33 -0
- data/test/integration/magazine_article_test.rb +33 -0
- data/test/integration/restricted_article_test.rb +33 -0
- data/test/integration/sport_article_test.rb +34 -0
- data/test/rails_app/Rakefile +6 -0
- data/test/rails_app/app/assets/javascripts/admin.coffee +137 -0
- data/test/rails_app/app/assets/javascripts/application.js +1 -0
- data/test/rails_app/app/assets/stylesheets/admin.scss +1 -0
- data/test/rails_app/app/assets/stylesheets/application.css +1 -0
- data/test/rails_app/app/controllers/admin/articles_controller.rb +7 -0
- data/test/rails_app/app/controllers/admin/base_controller.rb +8 -0
- data/test/rails_app/app/controllers/application_controller.rb +5 -0
- data/test/rails_app/app/helpers/application_helper.rb +2 -0
- data/test/rails_app/app/models/article.rb +46 -0
- data/test/rails_app/app/uploaders/article_image_uploader.rb +16 -0
- data/test/rails_app/app/views/admin/index.html.erb +4 -0
- data/test/rails_app/app/views/layouts/admin.html.erb +17 -0
- data/test/rails_app/app/views/layouts/application.html.erb +14 -0
- data/test/rails_app/bin/bundle +3 -0
- data/test/rails_app/bin/rails +8 -0
- data/test/rails_app/bin/rake +8 -0
- data/test/rails_app/bin/setup +29 -0
- data/test/rails_app/bin/spring +15 -0
- data/test/rails_app/config.ru +4 -0
- data/test/rails_app/config/application.rb +36 -0
- data/test/rails_app/config/boot.rb +3 -0
- data/test/rails_app/config/environment.rb +5 -0
- data/test/rails_app/config/environments/development.rb +38 -0
- data/test/rails_app/config/environments/production.rb +76 -0
- data/test/rails_app/config/environments/test.rb +46 -0
- data/test/rails_app/config/initializers/assets.rb +12 -0
- data/test/rails_app/config/initializers/backtrace_silencers.rb +7 -0
- data/test/rails_app/config/initializers/carrierwave.rb +5 -0
- data/test/rails_app/config/initializers/cookies_serializer.rb +3 -0
- data/test/rails_app/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/rails_app/config/initializers/inflections.rb +16 -0
- data/test/rails_app/config/initializers/mime_types.rb +4 -0
- data/test/rails_app/config/initializers/session_store.rb +3 -0
- data/test/rails_app/config/initializers/wrap_parameters.rb +9 -0
- data/test/rails_app/config/locales/en.yml +23 -0
- data/test/rails_app/config/mongoid.yml +9 -0
- data/test/rails_app/config/routes.rb +8 -0
- data/test/rails_app/config/secrets.yml +22 -0
- data/test/rails_app/db/seeds.rb +7 -0
- data/test/rails_app/public/404.html +67 -0
- data/test/rails_app/public/422.html +67 -0
- data/test/rails_app/public/500.html +66 -0
- data/{app/assets/javascripts/form/input-date.coffee → test/rails_app/public/favicon.ico} +0 -0
- data/test/rails_app/public/robots.txt +5 -0
- data/test/support/character_front_end.rb +196 -0
- data/test/support/chr/item.rb +32 -0
- data/test/support/chr/list.rb +31 -0
- data/test/support/chr/list_pagination.rb +163 -0
- data/test/support/chr/list_reorder.rb +46 -0
- data/test/support/chr/list_search.rb +41 -0
- data/test/support/chr/view.rb +112 -0
- data/test/support/stores/array.rb +20 -0
- data/test/support/stores/rest-array.rb +34 -0
- data/test/test_helper.rb +68 -0
- metadata +373 -80
- data/Gruntfile.coffee +0 -101
- data/app/assets/javascripts/form/expandable-group.coffee +0 -30
- data/app/assets/javascripts/form/form.coffee +0 -221
- data/app/assets/javascripts/form/input-checkbox.coffee +0 -83
- data/app/assets/javascripts/form/input-color.coffee +0 -55
- data/app/assets/javascripts/form/input-file.coffee +0 -144
- data/app/assets/javascripts/form/input-form.coffee +0 -171
- data/app/assets/javascripts/form/input-form_reorder.coffee +0 -67
- data/app/assets/javascripts/form/input-hidden.coffee +0 -57
- data/app/assets/javascripts/form/input-list.coffee +0 -154
- data/app/assets/javascripts/form/input-list_reorder.coffee +0 -39
- data/app/assets/javascripts/form/input-list_typeahead.coffee +0 -55
- data/app/assets/javascripts/form/input-password.coffee +0 -32
- data/app/assets/javascripts/form/input-select.coffee +0 -84
- data/app/assets/javascripts/form/input-select2.coffee +0 -33
- data/app/assets/javascripts/form/input-string.coffee +0 -160
- data/app/assets/javascripts/form/input-text.coffee +0 -43
- data/app/assets/javascripts/input-html.coffee +0 -81
- data/app/assets/javascripts/input-markdown.coffee +0 -93
- data/app/assets/javascripts/input-redactor.coffee +0 -1
- data/app/assets/javascripts/redactor/input-redactor.coffee +0 -53
- data/app/assets/javascripts/redactor/input-redactor_character.coffee +0 -83
- data/app/assets/javascripts/redactor/input-redactor_images.coffee +0 -166
- data/app/assets/javascripts/vendor/ace.js +0 -18280
- data/app/assets/javascripts/vendor/jquery.scrollparent.js +0 -14
- data/app/assets/javascripts/vendor/jquery.textarea_autosize.js +0 -55
- data/app/assets/javascripts/vendor/jquery.typeahead.js +0 -1782
- data/app/assets/javascripts/vendor/marked.js +0 -1272
- data/app/assets/javascripts/vendor/mode-html.js +0 -2436
- data/app/assets/javascripts/vendor/mode-markdown.js +0 -2820
- data/app/assets/javascripts/vendor/redactor.fixedtoolbar.js +0 -107
- data/app/assets/javascripts/vendor/select2.js +0 -5274
- data/app/assets/stylesheets/_input-redactor.scss +0 -35
- data/app/assets/stylesheets/form/_expandable-group.scss +0 -16
- data/app/assets/stylesheets/form/_input-select2.scss +0 -94
- data/app/assets/stylesheets/form/_main.scss +0 -180
- data/app/assets/stylesheets/vendor/select2.css +0 -258
- data/bower.json +0 -38
- data/dist/chr.js +0 -5949
- data/dist/input-ace.js +0 -24946
- data/dist/input-redactor.js +0 -1
- data/lib/mongoid/character.rb +0 -30
- data/package.json +0 -10
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module CharacterUploaderTest
|
|
2
|
+
|
|
3
|
+
def add_image(factory_name, list_of_modules)
|
|
4
|
+
test 'Add Image' do
|
|
5
|
+
instance_of_class = FactoryGirl.create(factory_name)
|
|
6
|
+
show_form_of_item(list_of_modules, instance_of_class.id)
|
|
7
|
+
upload_test_image_and_save
|
|
8
|
+
assert page.has_css?("a[data-id='#{instance_of_class.id}'] div img")
|
|
9
|
+
assert page.has_css?("input[name='[remove_image]']")
|
|
10
|
+
assert page.has_css?('a', text: 'test.jpg')
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def remove_image(factory_name, list_of_modules)
|
|
16
|
+
test 'Remove Image' do
|
|
17
|
+
instance_of_class = FactoryGirl.create(factory_name)
|
|
18
|
+
show_form_of_item(list_of_modules, instance_of_class.id)
|
|
19
|
+
upload_test_image_and_save
|
|
20
|
+
assert page.has_css?("a[data-id='#{instance_of_class.id}'] div img")
|
|
21
|
+
assert page.has_css?("input[name='[remove_image]']")
|
|
22
|
+
assert page.has_css?('a', text: 'test.jpg')
|
|
23
|
+
find("input[name='[remove_image]']").click
|
|
24
|
+
find_link('Save').click
|
|
25
|
+
wait_for_ajax
|
|
26
|
+
assert_not page.has_css?("a[data-id='#{instance_of_class.id}'] div img")
|
|
27
|
+
assert_not page.has_css?("input[name='[remove_image]']")
|
|
28
|
+
assert_not page.has_css?('a', text: 'test.jpg')
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module CharacterListTest
|
|
2
|
+
|
|
3
|
+
def show_with_parent(factory_name, list_of_modules)
|
|
4
|
+
test 'ShowWithParent: true' do
|
|
5
|
+
get_path_from_modules_list(list_of_modules)
|
|
6
|
+
instance_of_class = FactoryGirl.create(factory_name)
|
|
7
|
+
visit('/admin')
|
|
8
|
+
wait_for_ajax
|
|
9
|
+
# Select Module
|
|
10
|
+
select_last_module_from_list(list_of_modules)
|
|
11
|
+
assert page.has_css?("a[data-id='#{list_of_modules.last}']")
|
|
12
|
+
assert page.has_css?("a[data-id='#{instance_of_class.id}']")
|
|
13
|
+
assert page.has_css?('div.list-aside')
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def disable_new_item(factory_name, list_of_modules)
|
|
19
|
+
test 'DisableNewItems: true' do
|
|
20
|
+
instance_of_class = FactoryGirl.create(factory_name)
|
|
21
|
+
visit('/admin')
|
|
22
|
+
wait_for_ajax
|
|
23
|
+
# Select Module
|
|
24
|
+
select_last_module_from_list(list_of_modules)
|
|
25
|
+
get_path_from_modules_list(list_of_modules)
|
|
26
|
+
assert_not page.has_css?("a[href='##{@path}/new']")
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
end
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
module CharacterPaginationTest
|
|
2
|
+
|
|
3
|
+
def pagination(factory_name, class_name, list_of_modules)
|
|
4
|
+
test 'Pagination' do
|
|
5
|
+
create_per_page_plus_n_objects(50, factory_name)
|
|
6
|
+
visit('/admin')
|
|
7
|
+
wait_for_ajax
|
|
8
|
+
# Select Module
|
|
9
|
+
select_last_module_from_list(list_of_modules)
|
|
10
|
+
while @loaded_items < class_name.count do
|
|
11
|
+
sleep(2.0)
|
|
12
|
+
assert page.has_css?('div.item-title', count: @loaded_items)
|
|
13
|
+
scroll_to_bottom
|
|
14
|
+
wait_for_ajax
|
|
15
|
+
@loaded_items += @items_per_page
|
|
16
|
+
end
|
|
17
|
+
assert page.has_css?('div.item-title', count: class_name.count)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def click_back(factory_name, list_of_modules)
|
|
23
|
+
test 'Open last module in Hash and click back' do
|
|
24
|
+
instance_of_class = FactoryGirl.create(factory_name)
|
|
25
|
+
visit('/admin')
|
|
26
|
+
wait_for_ajax
|
|
27
|
+
# Select Module
|
|
28
|
+
select_last_module_from_list(list_of_modules)
|
|
29
|
+
list_of_modules -= [list_of_modules.last]
|
|
30
|
+
get_path_from_modules_list(list_of_modules)
|
|
31
|
+
find("a[href='##{@path}'].back", :text => 'Close').click
|
|
32
|
+
wait_for_ajax
|
|
33
|
+
assert_not page.has_css?("a[data-id='#{instance_of_class.id}']")
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def pagination_and_reorder(factory_name, class_name, list_of_modules)
|
|
39
|
+
test 'pagination_and_reorder' do
|
|
40
|
+
create_per_page_plus_n_objects(5, factory_name)
|
|
41
|
+
visit('/admin')
|
|
42
|
+
wait_for_ajax
|
|
43
|
+
select_last_module_from_list(list_of_modules)
|
|
44
|
+
while @loaded_items < class_name.count do
|
|
45
|
+
sleep(1.0)
|
|
46
|
+
assert page.has_css?('div.item-title', count: @loaded_items)
|
|
47
|
+
scroll_to_bottom
|
|
48
|
+
wait_for_ajax
|
|
49
|
+
drag_item(@instances_of_class[@loaded_items-5], @instances_of_class[@loaded_items-4])
|
|
50
|
+
@loaded_items += @items_per_page
|
|
51
|
+
end
|
|
52
|
+
assert page.has_css?('div.item-title', count: class_name.count)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def chage_position_to_end_and_check_pagination(factory_name, class_name, list_of_modules)
|
|
58
|
+
# If Module without disableFormCache need add reload page after "save"
|
|
59
|
+
test 'Change Position to the End and Check Pagination' do
|
|
60
|
+
create_per_page_plus_n_objects(2, factory_name)
|
|
61
|
+
show_form_of_item(list_of_modules, @first_item.id)
|
|
62
|
+
find('label.input-_position input').set(@last_item._position + 5)
|
|
63
|
+
find_link('Save').click
|
|
64
|
+
sleep(1.0)
|
|
65
|
+
assert page.has_css?('div.item-title', count: @loaded_items)
|
|
66
|
+
assert_not page.has_css?("a[data-id='#{@first_item.id}']")
|
|
67
|
+
scroll_to_bottom
|
|
68
|
+
assert page.has_css?('div.item-title', count: class_name.count)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def chage_position_to_middle_and_check_pagination(factory_name, class_name, list_of_modules)
|
|
74
|
+
# If Module without disableFormCache need add reload page after "save"
|
|
75
|
+
# Maybe not necessary
|
|
76
|
+
test 'Change Position to the Middle and Check Pagination' do
|
|
77
|
+
create_per_page_plus_n_objects(2, factory_name)
|
|
78
|
+
show_form_of_item(list_of_modules, @first_item.id)
|
|
79
|
+
find('label.input-_position input').set(@middle_item._position-1)
|
|
80
|
+
find_link('Save').click
|
|
81
|
+
sleep(1.0)
|
|
82
|
+
assert page.has_css?('div.item-title', count: @loaded_items)
|
|
83
|
+
title_middle_item = find("a[data-id='#{@first_item.id}']+a").text
|
|
84
|
+
title_moved_item = find("a[data-id='#{@before_middle_item.id}']+a").text
|
|
85
|
+
scroll_to_bottom
|
|
86
|
+
assert page.has_css?('div.item-title', count: class_name.count)
|
|
87
|
+
assert_equal @first_item.title, title_moved_item
|
|
88
|
+
assert_equal @middle_item.title, title_middle_item
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def chage_position_to_begin_and_check_pagination(factory_name, class_name, list_of_modules)
|
|
94
|
+
test 'Change Position to Begin and Check Pagination' do
|
|
95
|
+
create_per_page_plus_n_objects(2, factory_name)
|
|
96
|
+
show_form_of_item(list_of_modules, @last_item.id)
|
|
97
|
+
assert_not page.has_css?("a[data-id='#{@last_item.id}']")
|
|
98
|
+
find('label.input-_position input').set(@first_item._position - 5)
|
|
99
|
+
find_link('Save').click
|
|
100
|
+
# Reload page
|
|
101
|
+
visit('/admin')
|
|
102
|
+
select_last_module_from_list(list_of_modules)
|
|
103
|
+
assert page.has_css?('div.item-title', count: @loaded_items)
|
|
104
|
+
assert page.has_css?("a[data-id='#{@last_item.id}']")
|
|
105
|
+
assert_not page.has_css?("a[data-id='#{@last_item_on_first_page.id}']")
|
|
106
|
+
scroll_to_bottom
|
|
107
|
+
assert page.has_css?('div.item-title', count: class_name.count)
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def create_first_item_and_check_pagination(factory_name, class_name, list_of_modules)
|
|
113
|
+
test 'Create First Item and Check Pagination' do
|
|
114
|
+
create_per_page_plus_n_objects(2, factory_name)
|
|
115
|
+
visit('/admin')
|
|
116
|
+
wait_for_ajax
|
|
117
|
+
select_last_module_from_list(list_of_modules)
|
|
118
|
+
# Click "+"
|
|
119
|
+
get_path_from_modules_list(list_of_modules)
|
|
120
|
+
find("a[href='##{@path}/new']").click
|
|
121
|
+
find('label.input-title input').set("10 ways to lose weight")
|
|
122
|
+
find('label.input-_position input').set(@first_item._position - 5)
|
|
123
|
+
find_link('Save').click
|
|
124
|
+
# Reload page
|
|
125
|
+
visit('/admin')
|
|
126
|
+
select_last_module_from_list(list_of_modules)
|
|
127
|
+
|
|
128
|
+
assert page.has_css?('div.item-title', count: @loaded_items)
|
|
129
|
+
assert page.has_content?('10 ways to lose weight')
|
|
130
|
+
assert_not page.has_css?("a[data-id='#{@last_item_on_first_page.id}']")
|
|
131
|
+
scroll_to_bottom
|
|
132
|
+
assert page.has_css?('div.item-title', count: class_name.count)
|
|
133
|
+
assert page.has_css?("a[data-id='#{@last_item_on_first_page.id}']")
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def create_last_item_on_page_and_check_pagination(factory_name, class_name, list_of_modules)
|
|
139
|
+
test 'Create Last Item to Page and Check Pagination' do
|
|
140
|
+
create_per_page_plus_n_objects(2, factory_name)
|
|
141
|
+
visit('/admin')
|
|
142
|
+
wait_for_ajax
|
|
143
|
+
select_last_module_from_list(list_of_modules)
|
|
144
|
+
# Click "+"
|
|
145
|
+
get_path_from_modules_list(list_of_modules)
|
|
146
|
+
find("a[href='##{@path}/new']").click
|
|
147
|
+
find('label.input-title input').set("10 ways to lose weight")
|
|
148
|
+
find('label.input-_position input').set(@last_item_on_first_page._position - 1)
|
|
149
|
+
find_link('Save').click
|
|
150
|
+
# Reload page
|
|
151
|
+
visit('/admin')
|
|
152
|
+
select_last_module_from_list(list_of_modules)
|
|
153
|
+
|
|
154
|
+
assert page.has_css?('div.item-title', count: @loaded_items)
|
|
155
|
+
assert page.has_content?('10 ways to lose weight')
|
|
156
|
+
assert_not page.has_css?("a[data-id='#{@last_item_on_first_page.id}']")
|
|
157
|
+
scroll_to_bottom
|
|
158
|
+
assert page.has_css?('div.item-title', count: class_name.count)
|
|
159
|
+
assert page.has_css?("a[data-id='#{@last_item_on_first_page.id}']")
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
module CharacterReorderTest
|
|
2
|
+
|
|
3
|
+
def reorder(factory_name, class_name, list_of_modules)
|
|
4
|
+
test 'Reorder Items' do
|
|
5
|
+
create_n_objects(3, factory_name)
|
|
6
|
+
position_0_before = class_name.find(@instances_of_class[0].id)._position
|
|
7
|
+
position_1 = class_name.find(@instances_of_class[1].id)._position
|
|
8
|
+
position_2 = class_name.find(@instances_of_class[2].id)._position
|
|
9
|
+
visit('/admin')
|
|
10
|
+
wait_for_ajax
|
|
11
|
+
# Select Module
|
|
12
|
+
select_last_module_from_list(list_of_modules)
|
|
13
|
+
drag_item(@instances_of_class[0], @instances_of_class[1])
|
|
14
|
+
position_0_after = class_name.find(@instances_of_class[0].id)._position
|
|
15
|
+
title_2 = find("a[data-id='#{@instances_of_class[0].id}']+a").text
|
|
16
|
+
title_0 = find("a[data-id='#{@instances_of_class[1].id}']+a").text
|
|
17
|
+
|
|
18
|
+
assert page.has_css?('div.item-title', text: @instances_of_class[0].title, count: 1)
|
|
19
|
+
assert_not_equal position_0_before, position_0_after
|
|
20
|
+
assert position_0_after > position_1 && position_0_after < position_2
|
|
21
|
+
assert_equal @instances_of_class[0].title, title_0
|
|
22
|
+
assert_equal @instances_of_class[2].title, title_2
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def reorder_to_begin_of_list(factory_name, class_name, list_of_modules)
|
|
28
|
+
test 'Reorder Item in Begining of List' do
|
|
29
|
+
create_per_page_plus_n_objects(2, factory_name)
|
|
30
|
+
visit('/admin')
|
|
31
|
+
wait_for_ajax
|
|
32
|
+
select_last_module_from_list(list_of_modules)
|
|
33
|
+
wait_for_ajax
|
|
34
|
+
sleep(1.0)
|
|
35
|
+
assert page.has_css?('div.item-title', count: @loaded_items)
|
|
36
|
+
scroll_to_bottom
|
|
37
|
+
wait_for_ajax
|
|
38
|
+
scroll_to_bottom
|
|
39
|
+
drag_item(@last_item, @first_item)
|
|
40
|
+
title_second_item = find("a[data-id='#{@last_item.id}']+a").text
|
|
41
|
+
assert page.has_css?('div.item-title', count: class_name.count)
|
|
42
|
+
assert_equal @first_item.title, title_second_item
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
module CharacterSearchTest
|
|
2
|
+
|
|
3
|
+
def search(factory_name, list_of_modules)
|
|
4
|
+
test 'Search Item' do
|
|
5
|
+
create_n_objects(3, factory_name)
|
|
6
|
+
visit('/admin')
|
|
7
|
+
wait_for_ajax
|
|
8
|
+
# Select Module
|
|
9
|
+
select_last_module_from_list(list_of_modules)
|
|
10
|
+
wait_for_ajax
|
|
11
|
+
find('div.search a.icon').click
|
|
12
|
+
find('div.search input').set("#{@instances_of_class[0].title}\n")
|
|
13
|
+
wait_for_ajax
|
|
14
|
+
n = 1
|
|
15
|
+
2.times do
|
|
16
|
+
assert_not page.has_content?(@instances_of_class[n].title)
|
|
17
|
+
n += 1
|
|
18
|
+
end
|
|
19
|
+
assert page.has_content?(@instances_of_class[0].title)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def search_and_close(factory_name, class_name, list_of_modules)
|
|
25
|
+
test 'Search Item and Cancel (checking button "Cancel")' do
|
|
26
|
+
create_n_objects(3, factory_name)
|
|
27
|
+
visit('/admin')
|
|
28
|
+
wait_for_ajax
|
|
29
|
+
# Select Module
|
|
30
|
+
select_last_module_from_list(list_of_modules)
|
|
31
|
+
find('div.search a.icon').click
|
|
32
|
+
find('div.search input').set("#{@instances_of_class[0].title}\n")
|
|
33
|
+
wait_for_ajax
|
|
34
|
+
find_link('Cancel').click
|
|
35
|
+
class_name.each do |instance|
|
|
36
|
+
assert page.has_content?(instance.title)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
end
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
module CharacterViewTest
|
|
2
|
+
|
|
3
|
+
def show_item(factory_name, list_of_modules)
|
|
4
|
+
test 'Select Item and render its fields' do
|
|
5
|
+
instance_of_class = FactoryGirl.create(factory_name)
|
|
6
|
+
visit('/admin')
|
|
7
|
+
wait_for_ajax
|
|
8
|
+
# Select Module
|
|
9
|
+
select_last_module_from_list(list_of_modules)
|
|
10
|
+
# Select Item
|
|
11
|
+
find("div.item-title", :text => instance_of_class.title).click
|
|
12
|
+
wait_for_ajax
|
|
13
|
+
assert page.has_css?("section.view.#{list_of_modules.last}")
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def chage_title(factory_name, class_name, list_of_modules)
|
|
19
|
+
test 'Change Title of Item' do
|
|
20
|
+
instance_of_class = FactoryGirl.create(factory_name)
|
|
21
|
+
show_form_of_item(list_of_modules, instance_of_class.id)
|
|
22
|
+
find('label.input-title input').set("New sports diet")
|
|
23
|
+
find_link('Save').click
|
|
24
|
+
wait_for_ajax
|
|
25
|
+
assert page.has_content?('New sports diet')
|
|
26
|
+
assert_equal class_name.first.title, 'New sports diet'
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def add_item(factory_name, class_name, list_of_modules)
|
|
32
|
+
test 'Add Item' do
|
|
33
|
+
instance_of_class = FactoryGirl.create(factory_name)
|
|
34
|
+
count_of_objects = class_name.count
|
|
35
|
+
visit('/admin')
|
|
36
|
+
wait_for_ajax
|
|
37
|
+
# Select Module
|
|
38
|
+
select_last_module_from_list(list_of_modules)
|
|
39
|
+
# Click "+"
|
|
40
|
+
get_path_from_modules_list(list_of_modules)
|
|
41
|
+
find("a[href='##{@path}/new']").click
|
|
42
|
+
find('label.input-title input').set("10 ways to lose weight")
|
|
43
|
+
find_link('Save').click
|
|
44
|
+
wait_for_ajax
|
|
45
|
+
assert page.has_content?('10 ways to lose weight')
|
|
46
|
+
assert_equal count_of_objects + 1, class_name.count
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def delete_item(factory_name, class_name, list_of_modules)
|
|
52
|
+
test 'Delete Item' do
|
|
53
|
+
instance_of_class = FactoryGirl.create(factory_name)
|
|
54
|
+
count_of_objects = class_name.count
|
|
55
|
+
show_form_of_item(list_of_modules, instance_of_class.id)
|
|
56
|
+
find_link('Delete').click
|
|
57
|
+
wait_for_ajax
|
|
58
|
+
assert_not page.has_content?(instance_of_class.title)
|
|
59
|
+
assert_equal count_of_objects - 1, class_name.count
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def open_item_and_close(factory_name, list_of_modules)
|
|
65
|
+
test 'Open Item and Close (checking button "Close")' do
|
|
66
|
+
instance_of_class = FactoryGirl.create(factory_name)
|
|
67
|
+
show_form_of_item(list_of_modules, instance_of_class.id)
|
|
68
|
+
get_path_from_modules_list(list_of_modules)
|
|
69
|
+
find("a[href='##{@path}']", :text => 'Close').click
|
|
70
|
+
wait_for_ajax
|
|
71
|
+
assert_not page.has_css?("section.view.#{list_of_modules.last}")
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def disable_delete(factory_name, list_of_modules)
|
|
77
|
+
test 'DisableDelete: true' do
|
|
78
|
+
instance_of_class = FactoryGirl.create(factory_name)
|
|
79
|
+
show_form_of_item(list_of_modules, instance_of_class.id)
|
|
80
|
+
assert_not page.has_css?('a.view-delete', :text => 'Delete')
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def disable_save(factory_name, list_of_modules)
|
|
86
|
+
test 'DisableSave: true' do
|
|
87
|
+
instance_of_class = FactoryGirl.create(factory_name)
|
|
88
|
+
show_form_of_item(list_of_modules, instance_of_class.id)
|
|
89
|
+
assert_not page.has_css?('a.save', :text => 'Save')
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def fullsize_view(factory_name, list_of_modules)
|
|
95
|
+
test 'FullsizeView: true' do
|
|
96
|
+
instance_of_class = FactoryGirl.create(factory_name)
|
|
97
|
+
show_form_of_item(list_of_modules, instance_of_class.id)
|
|
98
|
+
assert page.has_css?('section.fullsize')
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def add_class_active(factory_name, list_of_modules)
|
|
104
|
+
test 'Adding Class Active' do
|
|
105
|
+
instance_of_class = FactoryGirl.create(factory_name)
|
|
106
|
+
show_form_of_item(list_of_modules, instance_of_class.id)
|
|
107
|
+
assert page.has_css?("a.menu-#{list_of_modules.first}.active")
|
|
108
|
+
assert page.has_css?("a[href='##{@path}/view/#{instance_of_class.id}'].active")
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module CharacterArrayTest
|
|
2
|
+
|
|
3
|
+
def sortReverse_by_position(factory_name, class_name, list_of_modules)
|
|
4
|
+
test 'Sort Reverse by Position' do
|
|
5
|
+
create_n_objects(10, factory_name)
|
|
6
|
+
last_item = @instances_of_class.last
|
|
7
|
+
n = 2
|
|
8
|
+
visit('/admin')
|
|
9
|
+
wait_for_ajax
|
|
10
|
+
select_last_module_from_list(list_of_modules)
|
|
11
|
+
while @instances_of_class.count+1 > n do
|
|
12
|
+
title = find("a[data-id='#{@instances_of_class[@instances_of_class.count-n+1].id}']+a").text
|
|
13
|
+
assert_equal title, @instances_of_class[@instances_of_class.count-n].title
|
|
14
|
+
n += 1
|
|
15
|
+
end
|
|
16
|
+
assert page.has_css?('a.is-object div.item-title', count: class_name.count)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|