web_admin 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (264) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.rspec +2 -0
  4. data/.ruby-version +1 -0
  5. data/Gemfile +32 -0
  6. data/Gemfile.lock +335 -0
  7. data/MIT-LICENSE +20 -0
  8. data/README.rdoc +3 -0
  9. data/Rakefile +22 -0
  10. data/app/assets/images/web_admin/.keep +0 -0
  11. data/app/assets/images/web_admin/avatar.jpg +0 -0
  12. data/app/assets/images/web_admin/first_icon.png +0 -0
  13. data/app/assets/images/web_admin/render-1-thumb.jpg +0 -0
  14. data/app/assets/images/web_admin/render-1.jpg +0 -0
  15. data/app/assets/images/web_admin/render-2-thumb.jpg +0 -0
  16. data/app/assets/images/web_admin/render-2.jpg +0 -0
  17. data/app/assets/images/web_admin/render-3-thumb.jpg +0 -0
  18. data/app/assets/images/web_admin/render-3.jpg +0 -0
  19. data/app/assets/images/web_admin/render-4-thumb.jpg +0 -0
  20. data/app/assets/images/web_admin/render-4.jpg +0 -0
  21. data/app/assets/images/web_admin/responsive.png +0 -0
  22. data/app/assets/javascripts/web_admin/app.data.js +336 -0
  23. data/app/assets/javascripts/web_admin/app.js +172 -0
  24. data/app/assets/javascripts/web_admin/app.plugin.js +220 -0
  25. data/app/assets/javascripts/web_admin/application.js +20 -0
  26. data/app/assets/javascripts/web_admin/bootstrap-filestyle.min.js +1 -0
  27. data/app/assets/javascripts/web_admin/bootstrap.js +1951 -0
  28. data/app/assets/javascripts/web_admin/charts/easypiechart/jquery.easy-pie-chart.js +184 -0
  29. data/app/assets/javascripts/web_admin/charts/sparkline/jquery.sparkline.min.js +5 -0
  30. data/app/assets/javascripts/web_admin/combodate/combodate.js +453 -0
  31. data/app/assets/javascripts/web_admin/combodate/moment.min.js +6 -0
  32. data/app/assets/javascripts/web_admin/data/datagrid.json +1900 -0
  33. data/app/assets/javascripts/web_admin/data/datatable.json +401 -0
  34. data/app/assets/javascripts/web_admin/datatables/jquery.dataTables.min.js +155 -0
  35. data/app/assets/javascripts/web_admin/datepicker/bootstrap-datepicker.js +474 -0
  36. data/app/assets/javascripts/web_admin/datepicker.js +3 -0
  37. data/app/assets/javascripts/web_admin/fuelux/fuelux.js +1645 -0
  38. data/app/assets/javascripts/web_admin/fullcalendar/fullcalendar.min.js +7 -0
  39. data/app/assets/javascripts/web_admin/grid/gallery.js +14 -0
  40. data/app/assets/javascripts/web_admin/grid/jquery.grid-a-licious.min.js +15 -0
  41. data/app/assets/javascripts/web_admin/grid/masonry.pkgd.min.js +9 -0
  42. data/app/assets/javascripts/web_admin/ie/excanvas.js +924 -0
  43. data/app/assets/javascripts/web_admin/ie/html5.js +9 -0
  44. data/app/assets/javascripts/web_admin/ie/respond.min.js +6 -0
  45. data/app/assets/javascripts/web_admin/jquery-ui-1.10.3.custom.min.js +6 -0
  46. data/app/assets/javascripts/web_admin/jquery.datetimepicker.js +1851 -0
  47. data/app/assets/javascripts/web_admin/jquery.ui.touch-punch.min.js +11 -0
  48. data/app/assets/javascripts/web_admin/parsley/parsley.min.js +35 -0
  49. data/app/assets/javascripts/web_admin/prettyphoto/default/default_thumb.png +0 -0
  50. data/app/assets/javascripts/web_admin/prettyphoto/default/loader.gif +0 -0
  51. data/app/assets/javascripts/web_admin/prettyphoto/default/sprite.png +0 -0
  52. data/app/assets/javascripts/web_admin/prettyphoto/default/sprite_next.png +0 -0
  53. data/app/assets/javascripts/web_admin/prettyphoto/default/sprite_prev.png +0 -0
  54. data/app/assets/javascripts/web_admin/prettyphoto/default/sprite_x.png +0 -0
  55. data/app/assets/javascripts/web_admin/prettyphoto/default/sprite_y.png +0 -0
  56. data/app/assets/javascripts/web_admin/prettyphoto/jquery.prettyPhoto.js +7 -0
  57. data/app/assets/javascripts/web_admin/prettyphoto/prettyPhoto.css +170 -0
  58. data/app/assets/javascripts/web_admin/select2/select2.css +652 -0
  59. data/app/assets/javascripts/web_admin/select2/select2.min.js +22 -0
  60. data/app/assets/javascripts/web_admin/slider/bootstrap-slider.js +388 -0
  61. data/app/assets/javascripts/web_admin/underscore-min.js +7 -0
  62. data/app/assets/javascripts/web_admin/underscore-min.map +1 -0
  63. data/app/assets/javascripts/web_admin/upload_image.js +39 -0
  64. data/app/assets/stylesheets/web_admin/application.css +15 -0
  65. data/app/assets/stylesheets/web_admin/bootstrap.css +5784 -0
  66. data/app/assets/stylesheets/web_admin/font-awesome.min.css +4 -0
  67. data/app/assets/stylesheets/web_admin/font.css +18 -0
  68. data/app/assets/stylesheets/web_admin/fonts/FontAwesome.otf +0 -0
  69. data/app/assets/stylesheets/web_admin/fonts/fontawesome-webfont.eot +0 -0
  70. data/app/assets/stylesheets/web_admin/fonts/fontawesome-webfont.svg +414 -0
  71. data/app/assets/stylesheets/web_admin/fonts/fontawesome-webfont.ttf +0 -0
  72. data/app/assets/stylesheets/web_admin/fonts/fontawesome-webfont.woff +0 -0
  73. data/app/assets/stylesheets/web_admin/fonts/glyphicons-halflings-regular.eot +0 -0
  74. data/app/assets/stylesheets/web_admin/fonts/glyphicons-halflings-regular.svg +229 -0
  75. data/app/assets/stylesheets/web_admin/fonts/glyphicons-halflings-regular.ttf +0 -0
  76. data/app/assets/stylesheets/web_admin/fonts/glyphicons-halflings-regular.woff +0 -0
  77. data/app/assets/stylesheets/web_admin/fonts/opensans/opensans-bold-webfont.woff +0 -0
  78. data/app/assets/stylesheets/web_admin/fonts/opensans/opensans-light-webfont.woff +0 -0
  79. data/app/assets/stylesheets/web_admin/fonts/opensans/opensans-webfont.woff +0 -0
  80. data/app/assets/stylesheets/web_admin/landing.css +272 -0
  81. data/app/assets/stylesheets/web_admin/plugin.css +1132 -0
  82. data/app/assets/stylesheets/web_admin/style.css +613 -0
  83. data/app/assets/stylesheets/web_admin/style2.css +21 -0
  84. data/app/controllers/web_admin/albums_controller.rb +8 -0
  85. data/app/controllers/web_admin/application_controller.rb +10 -0
  86. data/app/controllers/web_admin/crud_controller.rb +61 -0
  87. data/app/controllers/web_admin/events_controller.rb +9 -0
  88. data/app/controllers/web_admin/images_controller.rb +8 -0
  89. data/app/controllers/web_admin/institutionals_controller.rb +8 -0
  90. data/app/controllers/web_admin/main_controller.rb +7 -0
  91. data/app/controllers/web_admin/posts_controller.rb +19 -0
  92. data/app/controllers/web_admin/users_controller.rb +15 -0
  93. data/app/controllers/web_admin/videos_controller.rb +8 -0
  94. data/app/enumerations/web_admin/permission_type.rb +5 -0
  95. data/app/enumerations/web_admin/user_type.rb +6 -0
  96. data/app/helpers/web_admin/application_helper.rb +20 -0
  97. data/app/models/ability.rb +14 -0
  98. data/app/models/ckeditor/asset.rb +7 -0
  99. data/app/models/ckeditor/attachment_file.rb +7 -0
  100. data/app/models/ckeditor/picture.rb +7 -0
  101. data/app/models/web_admin/album.rb +13 -0
  102. data/app/models/web_admin/event.rb +20 -0
  103. data/app/models/web_admin/image.rb +10 -0
  104. data/app/models/web_admin/institutional.rb +11 -0
  105. data/app/models/web_admin/permission.rb +9 -0
  106. data/app/models/web_admin/post.rb +14 -0
  107. data/app/models/web_admin/user.rb +25 -0
  108. data/app/models/web_admin/video.rb +17 -0
  109. data/app/uploaders/ckeditor_attachment_file_uploader.rb +36 -0
  110. data/app/uploaders/ckeditor_picture_uploader.rb +47 -0
  111. data/app/uploaders/web_admin/image_post_uploader.rb +55 -0
  112. data/app/uploaders/web_admin/image_uploader.rb +52 -0
  113. data/app/views/devise/confirmations/new.html.erb +12 -0
  114. data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  115. data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  116. data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  117. data/app/views/devise/passwords/edit.html.erb +16 -0
  118. data/app/views/devise/passwords/new.html.erb +12 -0
  119. data/app/views/devise/registrations/edit.html.erb +29 -0
  120. data/app/views/devise/registrations/new.html.erb +18 -0
  121. data/app/views/devise/sessions/new.html.erb +16 -0
  122. data/app/views/devise/shared/_links.html.erb +25 -0
  123. data/app/views/devise/unlocks/new.html.erb +12 -0
  124. data/app/views/layouts/web_admin/devise.html.erb +42 -0
  125. data/app/views/shared/403.html +57 -0
  126. data/app/views/shared/_header.html.erb +16 -0
  127. data/app/views/shared/_navbar.html.erb +23 -0
  128. data/app/views/shared/_notice.html.erb +12 -0
  129. data/app/views/web_admin/albums/_form.html.erb +23 -0
  130. data/app/views/web_admin/albums/edit.html.erb +4 -0
  131. data/app/views/web_admin/albums/index.html.erb +39 -0
  132. data/app/views/web_admin/albums/new.html.erb +4 -0
  133. data/app/views/web_admin/albums/show.html.erb +4 -0
  134. data/app/views/web_admin/events/_form.html.erb +37 -0
  135. data/app/views/web_admin/events/edit.html.erb +4 -0
  136. data/app/views/web_admin/events/index.html.erb +39 -0
  137. data/app/views/web_admin/events/new.html.erb +4 -0
  138. data/app/views/web_admin/images/_form.html.erb +23 -0
  139. data/app/views/web_admin/images/_images.html.erb +10 -0
  140. data/app/views/web_admin/images/create.js.erb +2 -0
  141. data/app/views/web_admin/images/update.js.erb +2 -0
  142. data/app/views/web_admin/institutionals/_form.html.erb +22 -0
  143. data/app/views/web_admin/institutionals/edit.html.erb +4 -0
  144. data/app/views/web_admin/institutionals/index.html.erb +35 -0
  145. data/app/views/web_admin/institutionals/new.html.erb +4 -0
  146. data/app/views/web_admin/layouts/application.html.erb +77 -0
  147. data/app/views/web_admin/main/index.html.erb +1 -0
  148. data/app/views/web_admin/posts/_form.html.erb +27 -0
  149. data/app/views/web_admin/posts/edit.html.erb +4 -0
  150. data/app/views/web_admin/posts/index.html.erb +37 -0
  151. data/app/views/web_admin/posts/new.html.erb +4 -0
  152. data/app/views/web_admin/users/_form.html.erb +49 -0
  153. data/app/views/web_admin/users/edit.html.erb +4 -0
  154. data/app/views/web_admin/users/index.html.erb +35 -0
  155. data/app/views/web_admin/users/new.html.erb +4 -0
  156. data/app/views/web_admin/videos/_form.html.erb +22 -0
  157. data/app/views/web_admin/videos/edit.html.erb +4 -0
  158. data/app/views/web_admin/videos/index.html.erb +37 -0
  159. data/app/views/web_admin/videos/new.html.erb +4 -0
  160. data/bin/rails +12 -0
  161. data/config/initializers/ckeditor.rb +39 -0
  162. data/config/initializers/devise.rb +261 -0
  163. data/config/initializers/enumerate_it.rb +1 -0
  164. data/config/initializers/simple_form.rb +145 -0
  165. data/config/initializers/simple_form_bootstrap.rb +46 -0
  166. data/config/locales/buttons.yml +3 -0
  167. data/config/locales/controllers.yml +9 -0
  168. data/config/locales/devise.en.yml +62 -0
  169. data/config/locales/devise.pt.yml +62 -0
  170. data/config/locales/models.yml +54 -0
  171. data/config/locales/rails.yml +219 -0
  172. data/config/locales/responders.yml +10 -0
  173. data/config/locales/simple_form.en.yml +26 -0
  174. data/config/routes.rb +13 -0
  175. data/db/migrate/20141023223026_devise_create_admin_web_users.rb +42 -0
  176. data/db/migrate/20141023223656_create_admin_web_posts.rb +15 -0
  177. data/db/migrate/20141026181117_create_ckeditor_assets.rb +26 -0
  178. data/db/migrate/20141028020102_create_admin_web_institutionals.rb +10 -0
  179. data/db/migrate/20141028135201_create_admin_web_videos.rb +10 -0
  180. data/db/migrate/20141114020551_create_admin_web_albums.rb +12 -0
  181. data/db/migrate/20141117183405_create_admin_web_images.rb +11 -0
  182. data/db/migrate/20141130203155_add_user_type_to_users.rb +5 -0
  183. data/db/migrate/20141224221959_create_admin_web_events.rb +18 -0
  184. data/db/migrate/20150130140502_create_admin_web_permissions.rb +13 -0
  185. data/db/migrate/20150510191213_rename_tables.rb +12 -0
  186. data/lib/application_responder.rb +12 -0
  187. data/lib/tasks/web_admin_tasks.rake +4 -0
  188. data/lib/templates/erb/scaffold/_form.html.erb +13 -0
  189. data/lib/web_admin/engine.rb +15 -0
  190. data/lib/web_admin/version.rb +3 -0
  191. data/lib/web_admin.rb +18 -0
  192. data/spec/factories/admin_web_users.rb +24 -0
  193. data/spec/features/admin_web/albums_spec.rb +74 -0
  194. data/spec/features/admin_web/event_spec.rb +85 -0
  195. data/spec/features/admin_web/institutionals_spec.rb +47 -0
  196. data/spec/features/admin_web/login_spec.rb +18 -0
  197. data/spec/features/admin_web/permissions_spec.rb +40 -0
  198. data/spec/features/admin_web/posts_spec.rb +55 -0
  199. data/spec/features/admin_web/users_spec.rb +73 -0
  200. data/spec/features/admin_web/videos_spec.rb +51 -0
  201. data/spec/fixtures/p3-single.jpg +0 -0
  202. data/spec/models/admin_web/album_spec.rb +20 -0
  203. data/spec/models/admin_web/event_spec.rb +42 -0
  204. data/spec/models/admin_web/image_spec.rb +14 -0
  205. data/spec/models/admin_web/institutional_spec.rb +19 -0
  206. data/spec/models/admin_web/permission_spec.rb +14 -0
  207. data/spec/models/admin_web/post_spec.rb +25 -0
  208. data/spec/models/admin_web/user_spec.rb +18 -0
  209. data/spec/models/admin_web/video_spec.rb +26 -0
  210. data/spec/rails_helper.rb +52 -0
  211. data/spec/spec_helper.rb +85 -0
  212. data/spec/support/capybara.rb +53 -0
  213. data/spec/support/database_cleaner.rb +25 -0
  214. data/spec/support/devise.rb +5 -0
  215. data/spec/support/factory_girl.rb +4 -0
  216. data/spec/support/helpers.rb +82 -0
  217. data/spec/support/shared_connection.rb +10 -0
  218. data/spec/test_app/README.rdoc +28 -0
  219. data/spec/test_app/Rakefile +6 -0
  220. data/spec/test_app/app/assets/images/.keep +0 -0
  221. data/spec/test_app/app/assets/javascripts/application.js +13 -0
  222. data/spec/test_app/app/assets/stylesheets/application.css +15 -0
  223. data/spec/test_app/app/controllers/application_controller.rb +5 -0
  224. data/spec/test_app/app/controllers/concerns/.keep +0 -0
  225. data/spec/test_app/app/helpers/application_helper.rb +2 -0
  226. data/spec/test_app/app/mailers/.keep +0 -0
  227. data/spec/test_app/app/models/.keep +0 -0
  228. data/spec/test_app/app/models/concerns/.keep +0 -0
  229. data/spec/test_app/app/views/layouts/application.html.erb +14 -0
  230. data/spec/test_app/bin/bundle +3 -0
  231. data/spec/test_app/bin/rails +4 -0
  232. data/spec/test_app/bin/rake +4 -0
  233. data/spec/test_app/config/application.rb +29 -0
  234. data/spec/test_app/config/boot.rb +5 -0
  235. data/spec/test_app/config/database.yml +85 -0
  236. data/spec/test_app/config/environment.rb +5 -0
  237. data/spec/test_app/config/environments/development.rb +37 -0
  238. data/spec/test_app/config/environments/production.rb +78 -0
  239. data/spec/test_app/config/environments/test.rb +39 -0
  240. data/spec/test_app/config/initializers/assets.rb +8 -0
  241. data/spec/test_app/config/initializers/backtrace_silencers.rb +7 -0
  242. data/spec/test_app/config/initializers/cookies_serializer.rb +3 -0
  243. data/spec/test_app/config/initializers/filter_parameter_logging.rb +4 -0
  244. data/spec/test_app/config/initializers/inflections.rb +16 -0
  245. data/spec/test_app/config/initializers/mime_types.rb +4 -0
  246. data/spec/test_app/config/initializers/session_store.rb +3 -0
  247. data/spec/test_app/config/initializers/wrap_parameters.rb +14 -0
  248. data/spec/test_app/config/locales/en.yml +23 -0
  249. data/spec/test_app/config/routes.rb +4 -0
  250. data/spec/test_app/config/secrets.yml +22 -0
  251. data/spec/test_app/config.ru +4 -0
  252. data/spec/test_app/db/schema.rb +121 -0
  253. data/spec/test_app/lib/assets/.keep +0 -0
  254. data/spec/test_app/log/.keep +0 -0
  255. data/spec/test_app/public/404.html +67 -0
  256. data/spec/test_app/public/422.html +67 -0
  257. data/spec/test_app/public/500.html +66 -0
  258. data/spec/test_app/public/favicon.ico +0 -0
  259. data/spec/test_app/spec/factories/admin_web_albums.rb +7 -0
  260. data/spec/test_app/spec/factories/admin_web_users.rb +24 -0
  261. data/spec/test_app/spec/factories/permissions.rb +36 -0
  262. data/web_admin.gemspec +38 -0
  263. data/wercker.yml +16 -0
  264. metadata +530 -0
@@ -0,0 +1,13 @@
1
+ class CreateAdminWebPermissions < ActiveRecord::Migration
2
+ def change
3
+ create_table :admin_web_permissions do |t|
4
+ t.references :user
5
+ t.string :model
6
+ t.string :permission_type
7
+
8
+ t.timestamps
9
+ end
10
+
11
+ add_index :admin_web_permissions, :user_id
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ class RenameTables < ActiveRecord::Migration
2
+ def change
3
+ rename_table :admin_web_albums, :web_admin_albums
4
+ rename_table :admin_web_users, :web_admin_users
5
+ rename_table :admin_web_posts, :web_admin_posts
6
+ rename_table :admin_web_institutionals, :web_admin_institutionals
7
+ rename_table :admin_web_videos, :web_admin_videos
8
+ rename_table :admin_web_images, :web_admin_images
9
+ rename_table :admin_web_events, :web_admin_events
10
+ rename_table :admin_web_permissions, :web_admin_permissions
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ class ApplicationResponder < ActionController::Responder
2
+ include Responders::FlashResponder
3
+ include Responders::HttpCacheResponder
4
+
5
+ # Redirects resources to the collection path (index action) instead
6
+ # of the resource path (show action) for POST/PUT/DELETE requests.
7
+ include Responders::CollectionResponder
8
+
9
+ # Allows to use a callable object as the redirect location with respond_with,
10
+ # eg a route that requires persisted objects when the validation may fail.
11
+ # include Responders::LocationResponder
12
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :web_admin do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,13 @@
1
+ <%%= simple_form_for(@<%= singular_table_name %>) do |f| %>
2
+ <%%= f.error_notification %>
3
+
4
+ <div class="form-inputs">
5
+ <%- attributes.each do |attribute| -%>
6
+ <%%= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %> %>
7
+ <%- end -%>
8
+ </div>
9
+
10
+ <div class="form-actions">
11
+ <%%= f.button :submit %>
12
+ </div>
13
+ <%% end %>
@@ -0,0 +1,15 @@
1
+ module WebAdmin
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace WebAdmin
4
+
5
+ config.generators do |g|
6
+ g.test_framework :rspec
7
+ g.fixture_replacement :factory_girl, :dir => '../factories'
8
+ end
9
+
10
+ initializer("web_admin.locales") do |app|
11
+ WebAdmin::Engine.config.i18n.load_path += Dir[Rails.root.join('../../config/locales/', '*.{rb,yml}').to_s]
12
+ WebAdmin::Engine.config.i18n.default_locale = 'pt-BR'
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module WebAdmin
2
+ VERSION = "0.0.1"
3
+ end
data/lib/web_admin.rb ADDED
@@ -0,0 +1,18 @@
1
+ require 'devise'
2
+ require 'simple_form'
3
+ require 'ckeditor'
4
+ require 'carrierwave'
5
+ require 'i18n_alchemy'
6
+ require 'jquery-fileupload-rails'
7
+ require 'enumerate_it'
8
+ require 'cancan'
9
+ require 'responders'
10
+ require "web_admin/engine"
11
+
12
+ module WebAdmin
13
+ class Engine < ::Rails::Engine
14
+ config.to_prepare do
15
+ Devise::SessionsController.layout "web_admin/devise"
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,24 @@
1
+ FactoryGirl.define do
2
+ factory :web_admin_user, :class => 'WebAdmin::User' do
3
+ email "user@email.com"
4
+ password "12345678"
5
+ password_confirmation "12345678"
6
+
7
+ factory :web_admin_user_with_permission do
8
+ transient do
9
+ permissions_count 1
10
+ end
11
+
12
+ after(:create) do |user, evaluator|
13
+ create_list(:manager_user, evaluator.permissions_count, user: user)
14
+ create_list(:manager_video, evaluator.permissions_count, user: user)
15
+ create_list(:manager_post, evaluator.permissions_count, user: user)
16
+ create_list(:manager_album, evaluator.permissions_count, user: user)
17
+ create_list(:manager_image, evaluator.permissions_count, user: user)
18
+ create_list(:manager_insitutional, evaluator.permissions_count, user: user)
19
+ create_list(:manager_event, evaluator.permissions_count, user: user)
20
+ end
21
+ end
22
+ end
23
+
24
+ end
@@ -0,0 +1,74 @@
1
+ require 'rails_helper'
2
+
3
+ feature WebAdmin::Album do
4
+ background do
5
+ sign_in
6
+ end
7
+
8
+ scenario "create, update and destroy a institucional" do
9
+ click_link 'Álbuns'
10
+
11
+ expect(page).to have_content 'Cadastro de álbuns'
12
+
13
+ click_link 'Novo'
14
+
15
+ fill_in 'Título', with: "Álbum 1"
16
+ fill_in 'Local', with: "Local Álbum 1"
17
+ fill_in 'Data', with: I18n.l(Date.current)
18
+
19
+ click_button 'Salvar'
20
+
21
+ expect(page).to have_content "Álbum criado(a) com sucesso"
22
+
23
+ expect(page).to have_content "Álbum 1"
24
+ expect(page).to have_content "Local Álbum 1"
25
+ expect(page).to have_content I18n.l(Date.current)
26
+
27
+ click_link 'Álbum 1'
28
+
29
+ expect(page).to have_field "Título", with: "Álbum 1"
30
+ expect(page).to have_field "Local", with: "Local Álbum 1"
31
+ expect(page).to have_field "Data", with: I18n.l(Date.current)
32
+
33
+ fill_in 'Título', with: "Alterando o álbum 1"
34
+ fill_in 'Local', with: "Alterando o Local Álbum 1"
35
+ fill_in 'Data', with: I18n.l(Date.current + 3.day)
36
+
37
+ click_button "Salvar"
38
+
39
+ expect(page).to have_content "Álbum editado(a) com sucesso"
40
+
41
+ expect(page).to have_content "Alterando o álbum 1"
42
+ expect(page).to have_content "Alterando o Local Álbum 1"
43
+ expect(page).to have_content I18n.l(Date.current + 3.day)
44
+
45
+ click_link 'Alterando o álbum 1'
46
+
47
+ expect(page).to have_field "Título", with: "Alterando o álbum 1"
48
+ expect(page).to have_field "Local", with: "Alterando o Local Álbum 1"
49
+ expect(page).to have_field "Data", with: I18n.l(Date.current + 3.day)
50
+
51
+ click_link 'Apagar'
52
+
53
+ expect(page).to have_content "Álbum apagado(a) com sucesso"
54
+ end
55
+
56
+ scenario 'add images to album' do
57
+ create(:web_admin_album)
58
+
59
+ click_link 'Álbuns'
60
+
61
+ click_link 'Álbum 1'
62
+
63
+ expect(page).to have_field "Título", with: "Álbum 1"
64
+ expect(page).to have_field "Local", with: "Local album 1"
65
+ expect(page).to have_field "Data", with: I18n.l(Date.current)
66
+
67
+ click_link 'Adicionar imagens'
68
+
69
+ attach_file('Selecione o(s) arquivo(s)', "spec/fixtures/p3-single.jpg")
70
+
71
+ expect(page).to have_no_checked_field 'cover'
72
+
73
+ end
74
+ end
@@ -0,0 +1,85 @@
1
+ require 'rails_helper'
2
+
3
+ feature WebAdmin::Event do
4
+ background do
5
+ sign_in
6
+ end
7
+
8
+ scenario "create, update and destroy a event" do
9
+ click_link 'Eventos'
10
+
11
+ expect(page).to have_content 'Cadastro de eventos'
12
+
13
+ click_link 'Novo'
14
+
15
+ fill_in 'Título', with: "Evento 1"
16
+ fill_in 'Início às', with: '30/01/2015 21:00'
17
+ fill_in 'Término às', with: '31/01/2015 00:00'
18
+ fill_in 'Descrição', with: 'Descrição do evento 1'
19
+ fill_in 'CEP', with: '64000-128'
20
+ fill_in 'Logradouro', with: 'Rua João Damasceno'
21
+ fill_in 'Número', with: '3201'
22
+ fill_in 'Bairro', with: 'Planalto Ininga'
23
+ fill_in 'Cidade', with: 'Teresina'
24
+ fill_in 'Estado', with: 'Piauí'
25
+
26
+ click_button 'Salvar'
27
+
28
+ expect(page).to have_content "Evento criado(a) com sucesso"
29
+
30
+ expect(page).to have_content "Evento 1"
31
+ expect(page).to have_content "30/01/2015 21:00"
32
+ expect(page).to have_content "31/01/2015 00:00"
33
+ expect(page).to have_content I18n.l(Date.current)
34
+
35
+ click_link 'Evento 1'
36
+
37
+ expect(page).to have_field 'Título', with: "Evento 1"
38
+ expect(page).to have_field 'Início às', with: '30/01/2015 21:00'
39
+ expect(page).to have_field 'Término às', with: '31/01/2015 00:00'
40
+ expect(page).to have_field 'Descrição', with: 'Descrição do evento 1'
41
+ expect(page).to have_field 'CEP', with: '64000-128'
42
+ expect(page).to have_field 'Logradouro', with: 'Rua João Damasceno'
43
+ expect(page).to have_field 'Número', with: '3201'
44
+ expect(page).to have_field 'Bairro', with: 'Planalto Ininga'
45
+ expect(page).to have_field 'Cidade', with: 'Teresina'
46
+ expect(page).to have_field 'Estado', with: 'Piauí'
47
+
48
+ fill_in 'Título', with: "Alterando Evento 1"
49
+ fill_in 'Início às', with: '01/02/2015 21:00'
50
+ fill_in 'Término às', with: '02/02/2015 00:00'
51
+ fill_in 'Descrição', with: 'Alterando Descrição do evento 1'
52
+ fill_in 'CEP', with: '64000-128'
53
+ fill_in 'Logradouro', with: 'Rua Magalhães Filho'
54
+ fill_in 'Número', with: '712'
55
+ fill_in 'Bairro', with: 'Centro/Sul'
56
+ fill_in 'Cidade', with: 'Teresina'
57
+ fill_in 'Estado', with: 'Piauí'
58
+
59
+ click_button "Salvar"
60
+
61
+ expect(page).to have_content "Evento editado(a) com sucesso"
62
+
63
+ expect(page).to have_content "Alterando Evento 1"
64
+ expect(page).to have_content "01/02/2015 21:00"
65
+ expect(page).to have_content "02/02/2015 00:00"
66
+ expect(page).to have_content I18n.l(Date.current)
67
+
68
+ click_link 'Alterando Evento 1'
69
+
70
+ expect(page).to have_field 'Título', with: "Alterando Evento 1"
71
+ expect(page).to have_field 'Início às', with: '01/02/2015 21:00'
72
+ expect(page).to have_field 'Término às', with: '02/02/2015 00:00'
73
+ expect(page).to have_field 'Descrição', with: 'Alterando Descrição do evento 1'
74
+ expect(page).to have_field 'CEP', with: '64000-128'
75
+ expect(page).to have_field 'Logradouro', with: 'Rua Magalhães Filho'
76
+ expect(page).to have_field 'Número', with: '712'
77
+ expect(page).to have_field 'Bairro', with: 'Centro/Sul'
78
+ expect(page).to have_field 'Cidade', with: 'Teresina'
79
+ expect(page).to have_field 'Estado', with: 'Piauí'
80
+
81
+ click_link 'Apagar'
82
+
83
+ expect(page).to have_content "Evento apagado(a) com sucesso"
84
+ end
85
+ end
@@ -0,0 +1,47 @@
1
+ require 'rails_helper'
2
+
3
+ feature WebAdmin::Institutional do
4
+ background do
5
+ sign_in
6
+ end
7
+
8
+ scenario "create, update and destroy a institucional" do
9
+ click_link 'Institucionais'
10
+
11
+ expect(page).to have_content 'Cadastro de institucionais'
12
+
13
+ click_link 'Novo'
14
+
15
+ fill_in 'Título', with: "Institucional 1"
16
+ fill_in_ckeditor 'institutional_body', with: "Corpo da primeira página institucional"
17
+
18
+ click_button 'Salvar'
19
+
20
+ expect(page).to have_content "Institucional criado(a) com sucesso"
21
+
22
+ expect(page).to have_content "Institucional 1"
23
+ expect(page).to have_content I18n.l(Date.current)
24
+
25
+ click_link 'Institucional 1'
26
+
27
+ expect(page).to have_field "Título", with: "Institucional 1"
28
+
29
+ fill_in 'Título', with: "Alterando a institucional 1"
30
+ fill_in_ckeditor 'institutional_body', with: "Alterando o corpo da primeira página institucional"
31
+
32
+ click_button "Salvar"
33
+
34
+ expect(page).to have_content "Institucional editado(a) com sucesso"
35
+
36
+ expect(page).to have_content "Alterando a institucional 1"
37
+ expect(page).to have_content I18n.l(Date.current)
38
+
39
+ click_link 'Alterando a institucional 1'
40
+
41
+ expect(page).to have_field "Título", with: "Alterando a institucional 1"
42
+
43
+ click_link 'Apagar'
44
+
45
+ expect(page).to have_content "Institucional apagado(a) com sucesso"
46
+ end
47
+ end
@@ -0,0 +1,18 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe "Login", :type => :feature do
4
+ it "login" do
5
+ user = create(:web_admin_user)
6
+
7
+ visit web_admin.root_path
8
+
9
+ expect(page).to have_content "Acesso"
10
+
11
+ fill_in 'Email', with: "user@email.com"
12
+ fill_in 'Senha', with: "12345678"
13
+
14
+ click_button 'Entrar'
15
+
16
+ expect(page).to have_content "Bem vindo"
17
+ end
18
+ end
@@ -0,0 +1,40 @@
1
+ require 'rails_helper'
2
+
3
+ feature WebAdmin::Permission do
4
+ scenario "verify permission to user" do
5
+ user = create(:web_admin_user)
6
+ user.permissions = [
7
+ create(:manage_post, permission_type: WebAdmin::PermissionType::DENY),
8
+ create(:manage_user, permission_type: WebAdmin::PermissionType::ACCESS),
9
+ create(:manage_video, permission_type: WebAdmin::PermissionType::READ),
10
+ create(:manage_album, permission_type: WebAdmin::PermissionType::ACCESS),
11
+ create(:manage_image, permission_type: WebAdmin::PermissionType::ACCESS),
12
+ create(:manage_institutional, permission_type: WebAdmin::PermissionType::MODIFY),
13
+ create(:manage_event, permission_type: WebAdmin::PermissionType::ACCESS),
14
+ ]
15
+
16
+ visit web_admin.root_path
17
+ fill_in 'Email', with: user.email
18
+ fill_in 'Senha', with: user.password
19
+
20
+ click_button 'Entrar'
21
+
22
+ expect(page).to_not have_link 'Notícias'
23
+ expect(page).to have_link 'Institucionais'
24
+ expect(page).to have_link 'Vídeos'
25
+ expect(page).to have_link 'Álbuns'
26
+ expect(page).to have_link 'Usuários'
27
+ expect(page).to have_link 'Eventos'
28
+
29
+ visit '/web_admin/posts'
30
+ expect(page).to have_content "Você não tem acesso a essa página. Contate o administrador do sistema, para maiores informações."
31
+
32
+ visit web_admin.root_path
33
+
34
+ click_link 'Institucionais'
35
+
36
+ expect(page).to have_content "Cadastro de institucionais"
37
+ expect(page).to_not have_link 'Novo'
38
+
39
+ end
40
+ end
@@ -0,0 +1,55 @@
1
+ require 'rails_helper'
2
+
3
+ feature WebAdmin::Post do
4
+ background do
5
+ sign_in
6
+ end
7
+
8
+ scenario "create, update and destroy a post" do
9
+ click_link 'Notícias'
10
+
11
+ expect(page).to have_content 'Cadastro de notícias'
12
+
13
+ click_link 'Nova'
14
+
15
+ fill_in 'Título', with: "Primeira notícia"
16
+ fill_in 'Resumo', with: "Resumo da primeira notícia"
17
+
18
+ attach_file('Image', "spec/fixtures/p3-single.jpg")
19
+
20
+ fill_in_ckeditor 'post_body', with: "Corpo da primeira notícia"
21
+
22
+ click_button 'Salvar'
23
+
24
+ expect(page).to have_content "Notícia criado(a) com sucesso"
25
+
26
+ expect(page).to have_content "Primeira notícia"
27
+ expect(page).to have_content I18n.l(Date.current)
28
+
29
+ click_link 'Primeira notícia'
30
+
31
+ expect(page).to have_field "Título", with: "Primeira notícia"
32
+ expect(page).to have_field "Resumo", with: "Resumo da primeira notícia"
33
+
34
+ fill_in 'Título', with: "Alterando a primeira notícia"
35
+ fill_in 'Resumo', with: "Alterando o resumo da primeira notícia"
36
+
37
+ fill_in_ckeditor 'post_body', with: "Alterando o corpo da primeira notícia"
38
+
39
+ click_button "Salvar"
40
+
41
+ expect(page).to have_content "Notícia editado(a) com sucesso"
42
+
43
+ expect(page).to have_content "Alterando a primeira notícia"
44
+ expect(page).to have_content I18n.l(Date.current)
45
+
46
+ click_link 'Alterando a primeira notícia'
47
+
48
+ expect(page).to have_field "Título", with: "Alterando a primeira notícia"
49
+ expect(page).to have_field "Resumo", with: "Alterando o resumo da primeira notícia"
50
+
51
+ click_link 'Apagar'
52
+
53
+ expect(page).to have_content "Notícia apagado(a) com sucesso"
54
+ end
55
+ end
@@ -0,0 +1,73 @@
1
+ require "rails_helper"
2
+
3
+ feature WebAdmin::User do
4
+ background do
5
+ sign_in
6
+ end
7
+
8
+ scenario "create, update and destroy a user" do
9
+ click_link 'Usuários'
10
+
11
+ expect(page).to have_content 'Cadastro de usuários'
12
+
13
+ click_link 'Novo'
14
+
15
+ fill_in 'Email', with: "email@email.com"
16
+ fill_in 'Senha', with: "12345678"
17
+ fill_in 'Confirmação de senha', with: "12345678"
18
+ select 'Acesso total', from: 'user_permissions_attributes_0_permission_type'
19
+ select 'Acesso total', from: 'user_permissions_attributes_1_permission_type'
20
+ select 'Acesso total', from: 'user_permissions_attributes_2_permission_type'
21
+ select 'Acesso total', from: 'user_permissions_attributes_3_permission_type'
22
+ select 'Acesso total', from: 'user_permissions_attributes_4_permission_type'
23
+ select 'Acesso total', from: 'user_permissions_attributes_5_permission_type'
24
+
25
+ click_button 'Salvar'
26
+
27
+ expect(page).to have_content "Usuário criado(a) com sucesso"
28
+
29
+ expect(page).to have_content "email@email.com"
30
+ expect(page).to have_content I18n.l(Date.current)
31
+
32
+ click_link 'email@email.com'
33
+
34
+ expect(page).to have_field "Email", with: "email@email.com"
35
+ expect(page).to have_field "Senha", with: ""
36
+ expect(page).to have_field "Confirmação de senha", with: ""
37
+ expect(page).to have_select 'user_permissions_attributes_0_permission_type', selected: 'Acesso total'
38
+ expect(page).to have_select 'user_permissions_attributes_1_permission_type', selected: 'Acesso total'
39
+ expect(page).to have_select 'user_permissions_attributes_2_permission_type', selected: 'Acesso total'
40
+ expect(page).to have_select 'user_permissions_attributes_3_permission_type', selected: 'Acesso total'
41
+ expect(page).to have_select 'user_permissions_attributes_4_permission_type', selected: 'Acesso total'
42
+ expect(page).to have_select 'user_permissions_attributes_5_permission_type', selected: 'Acesso total'
43
+
44
+ fill_in 'Email', with: "email1@email.com"
45
+ select 'Acesso total', from: 'user_permissions_attributes_0_permission_type'
46
+ select 'Apenas leitura', from: 'user_permissions_attributes_1_permission_type'
47
+ select 'Bloqueado', from: 'user_permissions_attributes_2_permission_type'
48
+ select 'Atualizar', from: 'user_permissions_attributes_3_permission_type'
49
+ select 'Acesso total', from: 'user_permissions_attributes_4_permission_type'
50
+ select 'Acesso total', from: 'user_permissions_attributes_5_permission_type'
51
+
52
+ click_button "Salvar"
53
+
54
+ expect(page).to have_content "Usuário editado(a) com sucesso"
55
+
56
+ expect(page).to have_content "email1@email.com"
57
+ expect(page).to have_content I18n.l(Date.current)
58
+
59
+ click_link 'email1@email.com'
60
+
61
+ expect(page).to have_field "Email", with: "email1@email.com"
62
+ expect(page).to have_select 'user_permissions_attributes_0_permission_type', selected: 'Acesso total'
63
+ expect(page).to have_select 'user_permissions_attributes_1_permission_type', selected: 'Apenas leitura'
64
+ expect(page).to have_select 'user_permissions_attributes_2_permission_type', selected: 'Bloqueado'
65
+ expect(page).to have_select 'user_permissions_attributes_3_permission_type', selected: 'Atualizar'
66
+ expect(page).to have_select 'user_permissions_attributes_4_permission_type', selected: 'Acesso total'
67
+ expect(page).to have_select 'user_permissions_attributes_5_permission_type', selected: 'Acesso total'
68
+
69
+ click_link 'Apagar'
70
+
71
+ expect(page).to have_content "Usuário apagado(a) com sucesso"
72
+ end
73
+ end
@@ -0,0 +1,51 @@
1
+ require "rails_helper"
2
+
3
+ feature WebAdmin::Video do
4
+ background do
5
+ sign_in
6
+ end
7
+
8
+ scenario "create, update and destroy a video" do
9
+ click_link 'Vídeos'
10
+
11
+ expect(page).to have_content 'Cadastro de vídeos'
12
+
13
+ click_link 'Novo'
14
+
15
+ fill_in 'Descrição', with: "Primeiro vídeo"
16
+ fill_in 'Link do Youtube', with: "www.youtube.com/watch?v=uzxpH-MtIts"
17
+
18
+ click_button 'Salvar'
19
+
20
+ expect(page).to have_content "Vídeo criado(a) com sucesso"
21
+
22
+ expect(page).to have_content "Primeiro vídeo"
23
+ expect(page).to have_content "uzxpH-MtIts"
24
+ expect(page).to have_content I18n.l(Date.current)
25
+
26
+ click_link 'Primeiro vídeo'
27
+
28
+ expect(page).to have_field "Descrição", with: "Primeiro vídeo"
29
+ expect(page).to have_field "Link do Youtube", with: "uzxpH-MtIts"
30
+
31
+ fill_in 'Descrição', with: "Alterando a Primeiro vídeo"
32
+ fill_in 'Link do Youtube', with: "www.youtube.com/watch?v=uzxpH-MtItsdadada"
33
+
34
+ click_button "Salvar"
35
+
36
+ expect(page).to have_content "Vídeo editado(a) com sucesso"
37
+
38
+ expect(page).to have_content "Alterando a Primeiro vídeo"
39
+ expect(page).to have_content "uzxpH-MtItsdadada"
40
+ expect(page).to have_content I18n.l(Date.current)
41
+
42
+ click_link 'Alterando a Primeiro vídeo'
43
+
44
+ expect(page).to have_field "Descrição", with: "Alterando a Primeiro vídeo"
45
+ expect(page).to have_field 'Link do Youtube', with: "uzxpH-MtItsdadada"
46
+
47
+ click_link 'Apagar'
48
+
49
+ expect(page).to have_content "Vídeo apagado(a) com sucesso"
50
+ end
51
+ end
Binary file
@@ -0,0 +1,20 @@
1
+ require 'rails_helper'
2
+
3
+ module WebAdmin
4
+ RSpec.describe Album, :type => :model do
5
+ context "Validations" do
6
+ it { should validate_presence_of :title }
7
+ it { should validate_presence_of :date }
8
+ it { should validate_presence_of :local }
9
+ end
10
+
11
+ describe "to_s" do
12
+ it 'return title' do
13
+ subject.stub(title: "Primeiro Post")
14
+
15
+ expect(subject.to_s).to eq "Primeiro Post"
16
+ end
17
+
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,42 @@
1
+ require 'rails_helper'
2
+
3
+ module WebAdmin
4
+ RSpec.describe Event, :type => :model do
5
+ context "Validations" do
6
+ it { should validate_presence_of :title }
7
+ it { should validate_presence_of :start_date }
8
+ it { should validate_presence_of :end_date }
9
+ it { should validate_presence_of :description }
10
+
11
+ context "when end_date is greater than start_date" do
12
+ it 'is valid' do
13
+ subject.stub(start_date: Time.current)
14
+ subject.stub(end_date: Time.current + 3.days)
15
+
16
+ subject.valid?
17
+
18
+ expect(subject.errors[:end_date]).to be_empty
19
+ end
20
+ end
21
+
22
+ context "when end_date is less than start_date" do
23
+ it 'is not valid' do
24
+ subject.stub(start_date: Time.current)
25
+ subject.stub(end_date: Time.current - 3.days)
26
+
27
+ subject.valid?
28
+
29
+ expect(subject.errors[:end_date]).to eq([I18n.t('activerecord.errors.messages.end_date_is_greater_than_start_date')])
30
+ end
31
+ end
32
+ end
33
+
34
+ describe "to_s" do
35
+ it 'return title' do
36
+ subject.stub(title: "Primeiro Evento")
37
+
38
+ expect(subject.to_s).to eq "Primeiro Evento"
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,14 @@
1
+ require 'rails_helper'
2
+
3
+ module WebAdmin
4
+ RSpec.describe Image, :type => :model do
5
+ context "Relationships" do
6
+ it { should belong_to :album }
7
+ end
8
+
9
+ context "Validations" do
10
+ it { should validate_presence_of :album }
11
+ it { should validate_presence_of :file }
12
+ end
13
+ end
14
+ end