chr 0.3.5 → 0.4.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. checksums.yaml +4 -4
  2. data/.coveralls.yml +2 -0
  3. data/.gitignore +6 -1
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +18 -0
  6. data/README.md +4 -0
  7. data/Rakefile +17 -2
  8. data/app/assets/javascripts/chr.coffee +13 -26
  9. data/app/assets/javascripts/chr/{core/chr.coffee → chr.coffee} +4 -1
  10. data/app/assets/javascripts/chr/{core/chr_router.coffee → chr_router.coffee} +0 -0
  11. data/app/assets/javascripts/chr/{core/item.coffee → item.coffee} +2 -1
  12. data/app/assets/javascripts/chr/{core/list.coffee → list.coffee} +1 -1
  13. data/app/assets/javascripts/chr/{core/list_config.coffee → list_config.coffee} +0 -0
  14. data/app/assets/javascripts/chr/{core/list_pagination.coffee → list_pagination.coffee} +15 -4
  15. data/app/assets/javascripts/chr/{core/list_reorder.coffee → list_reorder.coffee} +0 -0
  16. data/app/assets/javascripts/chr/{core/list_search.coffee → list_search.coffee} +1 -1
  17. data/app/assets/javascripts/chr/{core/module.coffee → module.coffee} +0 -0
  18. data/app/assets/javascripts/chr/{core/utils.coffee → utils.coffee} +0 -0
  19. data/app/assets/javascripts/chr/{core/view.coffee → view.coffee} +21 -9
  20. data/app/assets/javascripts/chr/{core/view_local-storage.coffee → view_local-storage.coffee} +0 -0
  21. data/app/assets/javascripts/{chr/store/array-store.coffee → stores/array.coffee} +0 -0
  22. data/app/assets/javascripts/{chr/store/object-store.coffee → stores/object.coffee} +0 -0
  23. data/app/assets/javascripts/{chr/store/rails-array-store.coffee → stores/rails-array.coffee} +0 -0
  24. data/app/assets/javascripts/{chr/store → stores}/rails-form-object-parser.coffee +4 -1
  25. data/app/assets/javascripts/{chr/store/rails-object-store.coffee → stores/rails-object.coffee} +0 -0
  26. data/app/assets/javascripts/{chr/store/rest-array-store.coffee → stores/rest-array.coffee} +5 -2
  27. data/app/assets/javascripts/{chr/store/rest-object-store.coffee → stores/rest-object.coffee} +0 -0
  28. data/app/assets/stylesheets/{_chr.scss → chr.scss} +2 -7
  29. data/app/assets/stylesheets/chr/{_icons.scss → icons.scss} +0 -0
  30. data/app/assets/stylesheets/chr/{_main.scss → main.scss} +10 -3
  31. data/app/assets/stylesheets/chr/{_mixins.scss → mixins.scss} +0 -77
  32. data/app/assets/stylesheets/chr/{_settings.scss → settings.scss} +1 -1
  33. data/bin/chr +13 -0
  34. data/bin/rake +16 -0
  35. data/bin/setup +13 -0
  36. data/chr.gemspec +41 -21
  37. data/docs/tests.md +64 -0
  38. data/lib/chr.rb +10 -2
  39. data/lib/chr/app_builder.rb +385 -0
  40. data/lib/chr/generators/app_generator.rb +213 -0
  41. data/lib/chr/version.rb +3 -1
  42. data/lib/generators/chr/controller_generator.rb +18 -0
  43. data/templates/Gemfile.erb +38 -0
  44. data/templates/Procfile +1 -0
  45. data/templates/README.md.erb +45 -0
  46. data/templates/_analytics.html.erb +9 -0
  47. data/templates/_flashes.html.erb +7 -0
  48. data/templates/_javascript.html.erb +12 -0
  49. data/templates/application.coffee +2 -0
  50. data/templates/application.scss +1 -0
  51. data/templates/application.yml +6 -0
  52. data/templates/application_gitignore +14 -0
  53. data/templates/application_layout.html.erb.erb +29 -0
  54. data/templates/asset_sync.rb +28 -0
  55. data/templates/bin_setup.erb +36 -0
  56. data/templates/body_class_helper.rb +19 -0
  57. data/templates/bundler_audit.rake +12 -0
  58. data/templates/carrierwave.rb +23 -0
  59. data/templates/character_admin.coffee.erb +28 -0
  60. data/templates/character_admin.scss +3 -0
  61. data/templates/character_admin_index.html.erb +2 -0
  62. data/templates/character_admin_layout.html.erb +21 -0
  63. data/templates/character_base_controller.rb +16 -0
  64. data/templates/development_seeds.rb +12 -0
  65. data/templates/devise_overrides_passwords_controller.rb +10 -0
  66. data/templates/devise_overrides_passwords_edit.html.erb +30 -0
  67. data/templates/devise_overrides_passwords_new.html.erb +21 -0
  68. data/templates/devise_overrides_sessions_controller.rb +12 -0
  69. data/templates/devise_overrides_sessions_new.html.erb +31 -0
  70. data/templates/errors.rb +34 -0
  71. data/templates/json_encoding.rb +1 -0
  72. data/templates/newrelic.yml.erb +34 -0
  73. data/templates/puma.rb +18 -0
  74. data/templates/routes.rb +90 -0
  75. data/templates/sample.env +6 -0
  76. data/templates/secrets.yml +14 -0
  77. data/templates/smtp.rb +9 -0
  78. data/templates/staging.rb +5 -0
  79. data/test/factories/article_factory.rb +19 -0
  80. data/test/files/test.jpg +0 -0
  81. data/test/integration/article_fullsize_test.rb +33 -0
  82. data/test/integration/article_test.rb +33 -0
  83. data/test/integration/magazine_article_test.rb +33 -0
  84. data/test/integration/restricted_article_test.rb +33 -0
  85. data/test/integration/sport_article_test.rb +34 -0
  86. data/test/rails_app/Rakefile +6 -0
  87. data/test/rails_app/app/assets/javascripts/admin.coffee +137 -0
  88. data/test/rails_app/app/assets/javascripts/application.js +1 -0
  89. data/test/rails_app/app/assets/stylesheets/admin.scss +1 -0
  90. data/test/rails_app/app/assets/stylesheets/application.css +1 -0
  91. data/test/rails_app/app/controllers/admin/articles_controller.rb +7 -0
  92. data/test/rails_app/app/controllers/admin/base_controller.rb +8 -0
  93. data/test/rails_app/app/controllers/application_controller.rb +5 -0
  94. data/test/rails_app/app/helpers/application_helper.rb +2 -0
  95. data/test/rails_app/app/models/article.rb +46 -0
  96. data/test/rails_app/app/uploaders/article_image_uploader.rb +16 -0
  97. data/test/rails_app/app/views/admin/index.html.erb +4 -0
  98. data/test/rails_app/app/views/layouts/admin.html.erb +17 -0
  99. data/test/rails_app/app/views/layouts/application.html.erb +14 -0
  100. data/test/rails_app/bin/bundle +3 -0
  101. data/test/rails_app/bin/rails +8 -0
  102. data/test/rails_app/bin/rake +8 -0
  103. data/test/rails_app/bin/setup +29 -0
  104. data/test/rails_app/bin/spring +15 -0
  105. data/test/rails_app/config.ru +4 -0
  106. data/test/rails_app/config/application.rb +36 -0
  107. data/test/rails_app/config/boot.rb +3 -0
  108. data/test/rails_app/config/environment.rb +5 -0
  109. data/test/rails_app/config/environments/development.rb +38 -0
  110. data/test/rails_app/config/environments/production.rb +76 -0
  111. data/test/rails_app/config/environments/test.rb +46 -0
  112. data/test/rails_app/config/initializers/assets.rb +12 -0
  113. data/test/rails_app/config/initializers/backtrace_silencers.rb +7 -0
  114. data/test/rails_app/config/initializers/carrierwave.rb +5 -0
  115. data/test/rails_app/config/initializers/cookies_serializer.rb +3 -0
  116. data/test/rails_app/config/initializers/filter_parameter_logging.rb +4 -0
  117. data/test/rails_app/config/initializers/inflections.rb +16 -0
  118. data/test/rails_app/config/initializers/mime_types.rb +4 -0
  119. data/test/rails_app/config/initializers/session_store.rb +3 -0
  120. data/test/rails_app/config/initializers/wrap_parameters.rb +9 -0
  121. data/test/rails_app/config/locales/en.yml +23 -0
  122. data/test/rails_app/config/mongoid.yml +9 -0
  123. data/test/rails_app/config/routes.rb +8 -0
  124. data/test/rails_app/config/secrets.yml +22 -0
  125. data/test/rails_app/db/seeds.rb +7 -0
  126. data/test/rails_app/public/404.html +67 -0
  127. data/test/rails_app/public/422.html +67 -0
  128. data/test/rails_app/public/500.html +66 -0
  129. data/{app/assets/javascripts/form/input-date.coffee → test/rails_app/public/favicon.ico} +0 -0
  130. data/test/rails_app/public/robots.txt +5 -0
  131. data/test/support/character_front_end.rb +196 -0
  132. data/test/support/chr/item.rb +32 -0
  133. data/test/support/chr/list.rb +31 -0
  134. data/test/support/chr/list_pagination.rb +163 -0
  135. data/test/support/chr/list_reorder.rb +46 -0
  136. data/test/support/chr/list_search.rb +41 -0
  137. data/test/support/chr/view.rb +112 -0
  138. data/test/support/stores/array.rb +20 -0
  139. data/test/support/stores/rest-array.rb +34 -0
  140. data/test/test_helper.rb +68 -0
  141. metadata +373 -80
  142. data/Gruntfile.coffee +0 -101
  143. data/app/assets/javascripts/form/expandable-group.coffee +0 -30
  144. data/app/assets/javascripts/form/form.coffee +0 -221
  145. data/app/assets/javascripts/form/input-checkbox.coffee +0 -83
  146. data/app/assets/javascripts/form/input-color.coffee +0 -55
  147. data/app/assets/javascripts/form/input-file.coffee +0 -144
  148. data/app/assets/javascripts/form/input-form.coffee +0 -171
  149. data/app/assets/javascripts/form/input-form_reorder.coffee +0 -67
  150. data/app/assets/javascripts/form/input-hidden.coffee +0 -57
  151. data/app/assets/javascripts/form/input-list.coffee +0 -154
  152. data/app/assets/javascripts/form/input-list_reorder.coffee +0 -39
  153. data/app/assets/javascripts/form/input-list_typeahead.coffee +0 -55
  154. data/app/assets/javascripts/form/input-password.coffee +0 -32
  155. data/app/assets/javascripts/form/input-select.coffee +0 -84
  156. data/app/assets/javascripts/form/input-select2.coffee +0 -33
  157. data/app/assets/javascripts/form/input-string.coffee +0 -160
  158. data/app/assets/javascripts/form/input-text.coffee +0 -43
  159. data/app/assets/javascripts/input-html.coffee +0 -81
  160. data/app/assets/javascripts/input-markdown.coffee +0 -93
  161. data/app/assets/javascripts/input-redactor.coffee +0 -1
  162. data/app/assets/javascripts/redactor/input-redactor.coffee +0 -53
  163. data/app/assets/javascripts/redactor/input-redactor_character.coffee +0 -83
  164. data/app/assets/javascripts/redactor/input-redactor_images.coffee +0 -166
  165. data/app/assets/javascripts/vendor/ace.js +0 -18280
  166. data/app/assets/javascripts/vendor/jquery.scrollparent.js +0 -14
  167. data/app/assets/javascripts/vendor/jquery.textarea_autosize.js +0 -55
  168. data/app/assets/javascripts/vendor/jquery.typeahead.js +0 -1782
  169. data/app/assets/javascripts/vendor/marked.js +0 -1272
  170. data/app/assets/javascripts/vendor/mode-html.js +0 -2436
  171. data/app/assets/javascripts/vendor/mode-markdown.js +0 -2820
  172. data/app/assets/javascripts/vendor/redactor.fixedtoolbar.js +0 -107
  173. data/app/assets/javascripts/vendor/select2.js +0 -5274
  174. data/app/assets/stylesheets/_input-redactor.scss +0 -35
  175. data/app/assets/stylesheets/form/_expandable-group.scss +0 -16
  176. data/app/assets/stylesheets/form/_input-select2.scss +0 -94
  177. data/app/assets/stylesheets/form/_main.scss +0 -180
  178. data/app/assets/stylesheets/vendor/select2.css +0 -258
  179. data/bower.json +0 -38
  180. data/dist/chr.js +0 -5949
  181. data/dist/input-ace.js +0 -24946
  182. data/dist/input-redactor.js +0 -1
  183. data/lib/mongoid/character.rb +0 -30
  184. data/package.json +0 -10
@@ -0,0 +1,9 @@
1
+ test:
2
+ sessions:
3
+ default:
4
+ database: chr_test
5
+ hosts:
6
+ - localhost:27017
7
+ options:
8
+ max_retries: 1
9
+ retry_interval: 0
@@ -0,0 +1,8 @@
1
+ Rails.application.routes.draw do
2
+
3
+ namespace :admin do
4
+ get '/' => 'base#index'
5
+ resources :articles
6
+ end
7
+
8
+ end
@@ -0,0 +1,22 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rake secret` to generate a secure secret key.
9
+
10
+ # Make sure the secrets in this file are kept private
11
+ # if you're sharing your code publicly.
12
+
13
+ development:
14
+ secret_key_base: 76a38e5baef0e30f98596606c852231f513fe819a4c0047e96e8358854cb3dbdb1e48c467f5e66ad44bc5aae3f23e2b8d7dac1a2c8f4e3f0205852b06ccc7a21
15
+
16
+ test:
17
+ secret_key_base: 78638665c878ebebd67037541aa327d44450338cc839a6ee965df76b0420f1ac89ace2007914c1638011bc9ef38405cc67b9f1c7eaa8926060bc85c049812683
18
+
19
+ # Do not keep production secrets in the repository,
20
+ # instead read values from the environment.
21
+ production:
22
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
@@ -0,0 +1,7 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
+ #
4
+ # Examples:
5
+ #
6
+ # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
7
+ # Mayor.create(name: 'Emanuel', city: cities.first)
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/404.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The page you were looking for doesn't exist.</h1>
62
+ <p>You may have mistyped the address or the page may have moved.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/422.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The change you wanted was rejected.</h1>
62
+ <p>Maybe you tried to change something you didn't have access to.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/500.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>We're sorry, but something went wrong.</h1>
62
+ </div>
63
+ <p>If you are the application owner check the logs for more information.</p>
64
+ </div>
65
+ </body>
66
+ </html>
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-agent: *
5
+ # Disallow: /
@@ -0,0 +1,196 @@
1
+ #---------------------------------------------------------------------------------
2
+ ## List of functions
3
+
4
+ # show_item(factory_name, list_of_modules)
5
+ # chage_title(factory_name, class_name, list_of_modules)
6
+ # add_item(factory_name, class_name, list_of_modules)
7
+ # delete_item(factory_name, class_name, list_of_modules)
8
+ # open_item_and_close(factory_name, list_of_modules)
9
+ # search(factory_name, list_of_modules)
10
+ # search_and_close(factory_name, class_name, list_of_modules)
11
+ # reorder(factory_name, class_name, list_of_modules)
12
+ # show_with_parent(factory_name, list_of_modules)
13
+ # disable_new_item(factory_name, list_of_modules)
14
+ # disable_delete(factory_name, list_of_modules)
15
+ # disable_save(factory_name, list_of_modules)
16
+ # fullsize_view(factory_name, list_of_modules)
17
+ # add_class_active(factory_name, list_of_modules)
18
+ # pagination(factory_name, class_name, list_of_modules)
19
+ # pagination_and_reorder(factory_name, class_name, list_of_modules)
20
+ # click_back(factory_name, list_of_modules)
21
+ # chage_position_to_end_and_check_pagination(factory_name, class_name, list_of_modules)
22
+ # chage_position_to_begin_and_check_pagination(factory_name, class_name, list_of_modules)
23
+ # chage_position_to_middle_and_check_pagination(factory_name, class_name, list_of_modules)
24
+ # create_first_item_and_check_pagination(factory_name, class_name, list_of_modules)
25
+ # create_last_item_on_page_and_check_pagination(factory_name, class_name, list_of_modules)
26
+ # urlParams(factory_name, class_name, list_of_modules, config)
27
+ # remove_from_scope(factory_name, class_name, list_of_modules, config)
28
+ # sortReverse_by_position(factory_name, class_name, list_of_modules)
29
+ # add_image(factory_name, list_of_modules)
30
+ # remove_image(factory_name, list_of_modules)
31
+
32
+
33
+ #---------------------------------------------------------------------------------
34
+
35
+ Dir[Rails.root.join("../support/**/*.rb")].each{ |f| require f }
36
+ module CharacterFrontEnd
37
+ include CharacterListTest
38
+ include CharacterViewTest
39
+ include CharacterSearchTest
40
+ include CharacterReorderTest
41
+ include CharacterPaginationTest
42
+ include CharacterRestArrayTest
43
+ include CharacterArrayTest
44
+ include CharacterUploaderTest
45
+
46
+ def character_front_end(factory_name, class_name, list_of_modules, config)
47
+
48
+ show_item(factory_name, list_of_modules)
49
+ open_item_and_close(factory_name, list_of_modules)
50
+ add_class_active(factory_name, list_of_modules)
51
+
52
+ if config[:disableNewItems]
53
+ disable_new_item(factory_name, list_of_modules)
54
+ else
55
+ if config[:pagination]
56
+ create_first_item_and_check_pagination(factory_name, class_name, list_of_modules)
57
+ create_last_item_on_page_and_check_pagination(factory_name, class_name, list_of_modules)
58
+ end
59
+ add_item(factory_name, class_name, list_of_modules)
60
+ end
61
+
62
+ if config[:showWithParent]
63
+ show_with_parent(factory_name, list_of_modules)
64
+ end
65
+
66
+ if config[:searchable]
67
+ search(factory_name, list_of_modules)
68
+ search_and_close(factory_name, class_name, list_of_modules)
69
+ end
70
+
71
+ if config[:reorderable]
72
+ reorder(factory_name, class_name, list_of_modules)
73
+ if config[:pagination]
74
+ pagination_and_reorder(factory_name, class_name, list_of_modules)
75
+ reorder_to_begin_of_list(factory_name, class_name, list_of_modules)
76
+ end
77
+ end
78
+
79
+ if config[:disableDelete]
80
+ disable_delete(factory_name, list_of_modules)
81
+ else
82
+ delete_item(factory_name, class_name, list_of_modules)
83
+ end
84
+
85
+ if config[:disableSave]
86
+ disable_save(factory_name, list_of_modules)
87
+ else
88
+ if config[:pagination]
89
+ chage_position_to_end_and_check_pagination(factory_name, class_name, list_of_modules)
90
+ chage_position_to_begin_and_check_pagination(factory_name, class_name, list_of_modules)
91
+ chage_position_to_middle_and_check_pagination(factory_name, class_name, list_of_modules)
92
+ end
93
+ chage_title(factory_name, class_name, list_of_modules)
94
+ end
95
+
96
+ if config[:fullsizeView]
97
+ fullsize_view(factory_name, list_of_modules)
98
+ end
99
+
100
+ if config[:compoundModule]
101
+ click_back(factory_name, list_of_modules)
102
+ end
103
+
104
+ if config[:pagination]
105
+ pagination(factory_name, class_name, list_of_modules)
106
+ end
107
+
108
+ if config[:urlParams]
109
+ urlParams(factory_name, class_name, list_of_modules, config)
110
+ remove_from_scope(factory_name, class_name, list_of_modules, config)
111
+ end
112
+
113
+ if config[:sortReverse]
114
+ #TODO -> Double check, for correct work with reorderable and pagination
115
+ sortReverse_by_position(factory_name, class_name, list_of_modules)
116
+ end
117
+
118
+ if config[:uploaderImage]
119
+ add_image(factory_name, list_of_modules)
120
+ remove_image(factory_name, list_of_modules)
121
+ end
122
+
123
+ end
124
+
125
+ # save_and_open_screenshot
126
+
127
+ protected
128
+
129
+ def get_path_from_modules_list(list_of_modules)
130
+ @path = ''
131
+ list_of_modules.each do |module_name|
132
+ @path += '/' + module_name
133
+ end
134
+ end
135
+
136
+
137
+ def show_form_of_item(list_of_modules, item_id)
138
+ get_path_from_modules_list(list_of_modules)
139
+ visit("/admin##{@path}/view/#{item_id}")
140
+ wait_for_ajax
141
+ end
142
+
143
+
144
+ def select_last_module_from_list(list_of_modules)
145
+ path = ''
146
+ list_of_modules.each do |module_name|
147
+ path += '/' + module_name
148
+ find("a[href='##{path}']").click
149
+ wait_for_ajax
150
+ end
151
+ end
152
+
153
+
154
+ def create_n_objects(count, factory_name)
155
+ @instances_of_class = []
156
+ n = 0
157
+ count.times do
158
+ @instances_of_class[n] = FactoryGirl.create(factory_name)
159
+ n += 1
160
+ end
161
+ end
162
+
163
+
164
+ def create_per_page_plus_n_objects(n, factory_name)
165
+ y = current_window.size[1]
166
+ @items_per_page = ((y+50)/60)*2
167
+ @loaded_items = @items_per_page
168
+ create_n_objects(@items_per_page+n, factory_name)
169
+ @first_item = @instances_of_class.first
170
+ @last_item = @instances_of_class.last
171
+ @last_item_on_first_page = @instances_of_class[@items_per_page-1]
172
+ @middle_item = @instances_of_class[@items_per_page/2]
173
+ @before_middle_item = @instances_of_class[(@items_per_page/2)-1]
174
+ end
175
+
176
+
177
+ def scroll_to_bottom
178
+ page.execute_script(%Q{$("div.items").prop("scrollTop", 10000000).trigger('scroll')})
179
+ end
180
+
181
+
182
+ def drag_item(from, to)
183
+ source = find("a[data-id='#{from.id}']").find("div.icon-reorder")
184
+ target = find("a[data-id='#{to.id}']").find("div.icon-reorder")
185
+ source.drag_to(target)
186
+ wait_for_ajax
187
+ end
188
+
189
+
190
+ def upload_test_image_and_save
191
+ page.attach_file('[image]', Rails.root + '../files/test.jpg')
192
+ find_link('Save').click
193
+ wait_for_ajax
194
+ end
195
+
196
+ end