adminpanel 0.1.1 → 1.0.0

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.
Files changed (175) hide show
  1. data/.rspec +2 -2
  2. data/.ruby-version +1 -0
  3. data/.travis.yml +8 -8
  4. data/Gemfile +26 -24
  5. data/README.md +57 -57
  6. data/adminpanel.gemspec +41 -39
  7. data/app/assets/fonts/fontawesome-webfont.svg +254 -254
  8. data/app/assets/javascripts/adminpanel/bootstrap-datepicker.js +1159 -1159
  9. data/app/assets/javascripts/adminpanel/bootstrap-timepicker.js +803 -803
  10. data/app/assets/javascripts/adminpanel/bootstrap.js +2170 -2170
  11. data/app/assets/javascripts/adminpanel/{products.js → images_form.js} +13 -13
  12. data/app/assets/javascripts/adminpanel/imagesloaded.js +12 -12
  13. data/app/assets/javascripts/adminpanel/jquery.dataTables.min.js +155 -155
  14. data/app/assets/javascripts/adminpanel/jquery.facybox.js +395 -395
  15. data/app/assets/javascripts/adminpanel/jquery.masonry.min.js +9 -9
  16. data/app/assets/javascripts/adminpanel/jquery.slimscroll.min.js +13 -13
  17. data/app/assets/javascripts/adminpanel/medium-editor.js +702 -702
  18. data/app/assets/javascripts/adminpanel/realm.js +87 -87
  19. data/app/assets/javascripts/adminpanel/tables.js +126 -126
  20. data/app/assets/javascripts/application-admin.js +15 -15
  21. data/app/assets/stylesheets/adminpanel/_clearfix.css.scss +7 -7
  22. data/app/assets/stylesheets/adminpanel/alertify.css +241 -241
  23. data/app/assets/stylesheets/adminpanel/bootstrap.css +6103 -6103
  24. data/app/assets/stylesheets/adminpanel/colorpicker.css +6 -6
  25. data/app/assets/stylesheets/adminpanel/datepicker.css +9 -9
  26. data/app/assets/stylesheets/adminpanel/elfinder.min.css +59 -59
  27. data/app/assets/stylesheets/adminpanel/facybox.css +146 -146
  28. data/app/assets/stylesheets/adminpanel/font-awesome.min.css +33 -33
  29. data/app/assets/stylesheets/adminpanel/fullcalendar.css +618 -618
  30. data/app/assets/stylesheets/adminpanel/fullcalendar.print.css +61 -61
  31. data/app/assets/stylesheets/adminpanel/select2.css +524 -524
  32. data/app/assets/stylesheets/adminpanel/theme.css +1571 -1571
  33. data/app/assets/stylesheets/adminpanel/timepicker.css +82 -82
  34. data/app/assets/stylesheets/application-admin.css +13 -13
  35. data/app/controllers/adminpanel/application_controller.rb +32 -17
  36. data/app/controllers/adminpanel/galleries_controller.rb +80 -80
  37. data/app/controllers/adminpanel/sections_controller.rb +45 -45
  38. data/app/controllers/adminpanel/sessions_controller.rb +26 -26
  39. data/app/controllers/adminpanel/users_controller.rb +84 -84
  40. data/app/helpers/adminpanel/application_helper.rb +41 -51
  41. data/app/helpers/adminpanel/breadcrumbs_helper.rb +16 -0
  42. data/app/helpers/adminpanel/custom_form_builder.rb +248 -0
  43. data/app/helpers/adminpanel/images_helper.rb +9 -9
  44. data/app/helpers/adminpanel/rest_actions_helper.rb +47 -0
  45. data/app/helpers/adminpanel/router_helper.rb +33 -0
  46. data/app/helpers/adminpanel/sessions_helper.rb +25 -25
  47. data/app/models/adminpanel/gallery.rb +60 -60
  48. data/app/models/adminpanel/image.rb +14 -14
  49. data/app/models/adminpanel/section.rb +22 -22
  50. data/app/models/adminpanel/user.rb +35 -35
  51. data/app/uploaders/adminpanel/gallery_uploader.rb +55 -55
  52. data/app/uploaders/adminpanel/image_uploader.rb +57 -57
  53. data/app/views/adminpanel/galleries/_galleries_table.html.erb +14 -14
  54. data/app/views/adminpanel/galleries/create.html.erb +2 -2
  55. data/app/views/adminpanel/galleries/delete.html.erb +2 -2
  56. data/app/views/adminpanel/galleries/edit.html.erb +25 -25
  57. data/app/views/adminpanel/galleries/index.html.erb +51 -51
  58. data/app/views/adminpanel/galleries/new.html.erb +17 -17
  59. data/app/views/adminpanel/galleries/show.html.erb +17 -17
  60. data/app/views/adminpanel/galleries/update.html.erb +2 -2
  61. data/app/views/adminpanel/sections/_image_fields.html.erb +23 -23
  62. data/app/views/adminpanel/sections/_sections_table.html.erb +16 -16
  63. data/app/views/adminpanel/sections/create.html.erb +2 -2
  64. data/app/views/adminpanel/sections/destroy.html.erb +2 -2
  65. data/app/views/adminpanel/sections/edit.html.erb +41 -41
  66. data/app/views/adminpanel/sections/index.html.erb +44 -44
  67. data/app/views/adminpanel/sections/new.html.erb +26 -26
  68. data/app/views/adminpanel/sections/show.html.erb +30 -30
  69. data/app/views/adminpanel/sections/update.html.erb +2 -2
  70. data/app/views/adminpanel/sessions/new.html.erb +25 -25
  71. data/app/views/adminpanel/users/_user_form.html.erb +20 -20
  72. data/app/views/adminpanel/users/edit.html.erb +5 -5
  73. data/app/views/adminpanel/users/index.html.erb +49 -49
  74. data/app/views/adminpanel/users/new.html.erb +5 -5
  75. data/app/views/adminpanel/users/show.html.erb +20 -20
  76. data/app/views/layouts/_shim.html.erb +3 -3
  77. data/app/views/layouts/_side_menu.html.erb +49 -43
  78. data/app/views/layouts/_top_bar.html.erb +43 -43
  79. data/app/views/layouts/admin-login.html.erb +28 -28
  80. data/app/views/layouts/admin.html.erb +41 -39
  81. data/app/views/shared/_breadcrumb.html.erb +6 -6
  82. data/app/views/shared/_error_messages.html.erb +16 -16
  83. data/app/views/shared/_form_fields.html.erb +25 -0
  84. data/app/views/{adminpanel/products → shared}/_image_fields.html.erb +23 -23
  85. data/app/views/shared/_init_editor.html.erb +24 -0
  86. data/app/views/shared/edit.html.erb +28 -0
  87. data/app/views/shared/index.html.erb +94 -0
  88. data/app/views/shared/new.html.erb +28 -0
  89. data/app/views/shared/show.html.erb +63 -0
  90. data/config/locales/en.yml +5 -5
  91. data/config/locales/es.yml +127 -129
  92. data/config/routes.rb +24 -16
  93. data/lib/adminpanel.rb +9 -7
  94. data/lib/adminpanel/active_record_extension.rb +38 -0
  95. data/lib/adminpanel/engine.rb +5 -5
  96. data/lib/adminpanel/version.rb +3 -3
  97. data/lib/generators/adminpanel/initialize/initialize_generator.rb +17 -0
  98. data/lib/generators/adminpanel/{install/templates/migrations → initialize/templates}/create_adminpanel_tables.rb +45 -64
  99. data/lib/generators/adminpanel/resource/resource_generator.rb +105 -0
  100. data/lib/generators/adminpanel/resource/templates/controller.rb +4 -0
  101. data/lib/generators/adminpanel/resource/templates/migration.rb +9 -0
  102. data/lib/generators/adminpanel/resource/templates/resource.rb +19 -0
  103. data/spec/dummy/.gitignore +17 -17
  104. data/spec/dummy/README.rdoc +261 -261
  105. data/spec/dummy/Rakefile +7 -7
  106. data/{app/views/adminpanel/categories/show.html.erb → spec/dummy/app/adminpanel/products.rb} +0 -0
  107. data/spec/dummy/app/assets/javascripts/application.js +13 -13
  108. data/spec/dummy/app/assets/stylesheets/application.css +13 -13
  109. data/spec/dummy/app/controllers/adminpanel/.gitkeep +0 -0
  110. data/spec/dummy/app/controllers/application_controller.rb +3 -11
  111. data/spec/dummy/app/helpers/application_helper.rb +2 -2
  112. data/spec/dummy/app/views/layouts/application.html.erb +14 -14
  113. data/spec/dummy/config.ru +4 -4
  114. data/spec/dummy/config/application.rb +62 -62
  115. data/spec/dummy/config/boot.rb +9 -9
  116. data/spec/dummy/config/carrierwve.rb +5 -5
  117. data/spec/dummy/config/database.yml +24 -24
  118. data/spec/dummy/config/environment.rb +5 -5
  119. data/spec/dummy/config/environments/development.rb +41 -41
  120. data/spec/dummy/config/environments/production.rb +72 -72
  121. data/spec/dummy/config/environments/test.rb +41 -41
  122. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -7
  123. data/spec/dummy/config/initializers/inflections.rb +15 -15
  124. data/spec/dummy/config/initializers/mime_types.rb +5 -5
  125. data/spec/dummy/config/initializers/secret_token.rb +8 -8
  126. data/spec/dummy/config/initializers/session_store.rb +8 -8
  127. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -14
  128. data/spec/dummy/config/locales/en.yml +5 -5
  129. data/spec/dummy/config/routes.rb +4 -4
  130. data/spec/dummy/db/schema.rb +15 -15
  131. data/spec/dummy/public/404.html +26 -26
  132. data/spec/dummy/public/422.html +26 -26
  133. data/spec/dummy/public/500.html +25 -25
  134. data/spec/dummy/public/uploads/gallery/file/1/hipster.jpg +0 -0
  135. data/spec/dummy/public/uploads/gallery/file/1/thumb_hipster.jpg +0 -0
  136. data/spec/dummy/script/rails +6 -6
  137. data/spec/features/authentication_pages_spec.rb +43 -43
  138. data/spec/features/galleries_pages_spec.rb +124 -124
  139. data/spec/features/section_pages_spec.rb +37 -37
  140. data/spec/features/user_pages_spec.rb +48 -48
  141. data/spec/generators/initialize_spec.rb +9 -0
  142. data/spec/generators/resource_spec.rb +122 -0
  143. data/spec/models/gallery_spec.rb +21 -21
  144. data/spec/models/section_spec.rb +66 -66
  145. data/spec/models/user_spec.rb +105 -105
  146. data/spec/spec_helper.rb +32 -31
  147. data/spec/support/define_factory_models.rb +25 -36
  148. data/spec/support/helper_methods.rb +26 -26
  149. data/spec/support/submit_forms_without_button.rb +16 -16
  150. data/spec/support/test_database.rb +45 -58
  151. data/spec/uploaders/gallery_uploader_spec.rb +36 -30
  152. data/spec/uploaders/image_uploader_spec.rb +30 -29
  153. metadata +208 -64
  154. checksums.yaml +0 -7
  155. data/app/assets/javascripts/adminpanel/init_editor.js +0 -28
  156. data/app/controllers/adminpanel/categories_controller.rb +0 -41
  157. data/app/controllers/adminpanel/products_controller.rb +0 -88
  158. data/app/helpers/custom_form_builder.rb +0 -219
  159. data/app/models/adminpanel/category.rb +0 -7
  160. data/app/models/adminpanel/product.rb +0 -24
  161. data/app/views/adminpanel/categories/edit.html.erb +0 -18
  162. data/app/views/adminpanel/categories/index.html.erb +0 -55
  163. data/app/views/adminpanel/categories/new.html.erb +0 -18
  164. data/app/views/adminpanel/products/.DS_Store +0 -0
  165. data/app/views/adminpanel/products/_product_form.html.erb +0 -31
  166. data/app/views/adminpanel/products/edit.html.erb +0 -10
  167. data/app/views/adminpanel/products/index.html.erb +0 -51
  168. data/app/views/adminpanel/products/new.html.erb +0 -10
  169. data/app/views/adminpanel/products/show.html.erb +0 -61
  170. data/config/database.yml +0 -24
  171. data/lib/generators/adminpanel/install/install_generator.rb +0 -12
  172. data/spec/features/categories_pages_spec.rb +0 -44
  173. data/spec/features/product_pages_spec.rb +0 -64
  174. data/spec/models/category_spec.rb +0 -58
  175. data/spec/models/product_spec.rb +0 -51
@@ -1,125 +1,125 @@
1
- require "spec_helper"
2
-
3
- describe "Gallery pages" do
4
- subject {page}
5
-
6
- let(:user) { Factory(:user) }
7
- before do
8
- visit adminpanel.signin_path
9
- valid_signin(user)
10
- clean_uploads_folder
11
- end
12
-
13
- describe "galleries" do
14
- let(:gallery) { Factory(:gallery) }
15
- before do
16
- visit adminpanel.galleries_path
17
- end
18
-
19
- it { should have_link(I18n.t("gallery.new"), adminpanel.new_gallery_path)}
20
- it { should have_link("i", adminpanel.gallery_path(gallery)) }
21
- it { should have_link("i", adminpanel.edit_gallery_path(gallery)) }
22
- it { should have_link("i", adminpanel.move_to_better_gallery_path(gallery)) }
23
- it { should have_link("i", adminpanel.move_to_worst_gallery_path(gallery)) }
24
- end
25
-
26
- describe "when creating" do
27
- describe "a single image" do
28
- let(:gallery) { Factory(:gallery)}
29
- it { gallery.position.should eq 1 }
30
- end
31
-
32
- describe "3 images" do
33
- let!(:gallery_1) { Factory(:gallery) }
34
- let!(:gallery_2) { Factory(:gallery) }
35
- let!(:gallery_3) { Factory(:gallery) }
36
-
37
- it { gallery_2.position.should eq 2 }
38
- it { gallery_3.position.should eq 3 }
39
- describe "when moving down the image in position 1" do
40
- before do
41
- gallery_1.move_to_worst_position
42
- gallery_2.reload
43
- gallery_3.reload
44
- end
45
-
46
- it { gallery_1.move_to_worst_position.should eq true}
47
- it { gallery_3.move_to_worst_position.should eq false}
48
- it { gallery_1.position.should eq 2}
49
- it { gallery_2.position.should eq 1}
50
- it { gallery_3.position.should eq 3}
51
-
52
- after do
53
- gallery_1.position = 1
54
- gallery_2.position = 2
55
- gallery_3.position = 3
56
- end
57
- end
58
-
59
- describe "when moving up the image in position 2" do
60
- before do
61
- gallery_2.move_to_better_position
62
- gallery_1.reload
63
- gallery_3.reload
64
- end
65
-
66
- it { gallery_1.move_to_better_position.should eq true}
67
- it { gallery_2.move_to_better_position.should eq false}
68
- it { gallery_1.position.should eq 2}
69
- it { gallery_2.position.should eq 1}
70
- it { gallery_3.position.should eq 3}
71
-
72
- after do
73
- gallery_1.position = 1
74
- gallery_2.position = 2
75
- gallery_3.position = 3
76
- end
77
- end
78
-
79
- describe "when deleting the image in position 1" do
80
- before do
81
- gallery_1.destroy
82
- gallery_2.reload
83
- gallery_3.reload
84
- end
85
-
86
- it { gallery_2.position.should eq 1}
87
- it { gallery_3.position.should eq 2}
88
- end
89
- end
90
- end
91
-
92
- describe "new" do
93
- before do
94
- visit adminpanel.new_gallery_path
95
- end
96
-
97
- it { should have_title(I18n.t("gallery.new")) }
98
-
99
- describe "with invalid information" do
100
- before { find("form#new_gallery").submit_form! }
101
-
102
- it { should have_title(I18n.t("gallery.new")) }
103
- it { should have_selector("div#alerts") }
104
- end
105
-
106
- describe "with valid information" do
107
- before do
108
- attach_file('gallery_file', File.join(Rails.root, '/app/assets/images/hipster.jpg'))
109
- find("form#new_gallery").submit_form!
110
- end
111
-
112
- it { should have_content(I18n.t("gallery.success"))}
113
- it { File.exists? File.join(Rails.root, '/public/uploads/gallery/file/1/thumb_hipster.jpg') }
114
- end
115
- end
116
-
117
- describe "show" do
118
- let(:gallery) { Factory(:gallery) }
119
- before do
120
- visit adminpanel.gallery_path(gallery)
121
- end
122
-
123
- it { page.should have_selector("img", :src => gallery.file_url) }
124
- end
1
+ require "spec_helper"
2
+
3
+ describe "Gallery pages" do
4
+ subject {page}
5
+
6
+ let(:user) { Factory(:user) }
7
+ before do
8
+ visit adminpanel.signin_path
9
+ valid_signin(user)
10
+ clean_uploads_folder
11
+ end
12
+
13
+ describe "galleries" do
14
+ let(:gallery) { Factory(:gallery) }
15
+ before do
16
+ visit adminpanel.galleries_path
17
+ end
18
+
19
+ it { should have_link(I18n.t("gallery.new"), adminpanel.new_gallery_path)}
20
+ it { should have_link("i", adminpanel.gallery_path(gallery)) }
21
+ it { should have_link("i", adminpanel.edit_gallery_path(gallery)) }
22
+ it { should have_link("i", adminpanel.move_to_better_gallery_path(gallery)) }
23
+ it { should have_link("i", adminpanel.move_to_worst_gallery_path(gallery)) }
24
+ end
25
+
26
+ describe "when creating" do
27
+ describe "a single image" do
28
+ let(:gallery) { Factory(:gallery)}
29
+ it { gallery.position.should eq 1 }
30
+ end
31
+
32
+ describe "3 images" do
33
+ let!(:gallery_1) { Factory(:gallery) }
34
+ let!(:gallery_2) { Factory(:gallery) }
35
+ let!(:gallery_3) { Factory(:gallery) }
36
+
37
+ it { gallery_2.position.should eq 2 }
38
+ it { gallery_3.position.should eq 3 }
39
+ describe "when moving down the image in position 1" do
40
+ before do
41
+ gallery_1.move_to_worst_position
42
+ gallery_2.reload
43
+ gallery_3.reload
44
+ end
45
+
46
+ it { gallery_1.move_to_worst_position.should eq true}
47
+ it { gallery_3.move_to_worst_position.should eq false}
48
+ it { gallery_1.position.should eq 2}
49
+ it { gallery_2.position.should eq 1}
50
+ it { gallery_3.position.should eq 3}
51
+
52
+ after do
53
+ gallery_1.position = 1
54
+ gallery_2.position = 2
55
+ gallery_3.position = 3
56
+ end
57
+ end
58
+
59
+ describe "when moving up the image in position 2" do
60
+ before do
61
+ gallery_2.move_to_better_position
62
+ gallery_1.reload
63
+ gallery_3.reload
64
+ end
65
+
66
+ it { gallery_1.move_to_better_position.should eq true}
67
+ it { gallery_2.move_to_better_position.should eq false}
68
+ it { gallery_1.position.should eq 2}
69
+ it { gallery_2.position.should eq 1}
70
+ it { gallery_3.position.should eq 3}
71
+
72
+ after do
73
+ gallery_1.position = 1
74
+ gallery_2.position = 2
75
+ gallery_3.position = 3
76
+ end
77
+ end
78
+
79
+ describe "when deleting the image in position 1" do
80
+ before do
81
+ gallery_1.destroy
82
+ gallery_2.reload
83
+ gallery_3.reload
84
+ end
85
+
86
+ it { gallery_2.position.should eq 1}
87
+ it { gallery_3.position.should eq 2}
88
+ end
89
+ end
90
+ end
91
+
92
+ describe "new" do
93
+ before do
94
+ visit adminpanel.new_gallery_path
95
+ end
96
+
97
+ it { should have_title(I18n.t("gallery.new")) }
98
+
99
+ describe "with invalid information" do
100
+ before { find("form#new_gallery").submit_form! }
101
+
102
+ it { should have_title(I18n.t("gallery.new")) }
103
+ it { should have_selector("div#alerts") }
104
+ end
105
+
106
+ describe "with valid information" do
107
+ before do
108
+ attach_file('gallery_file', File.join(Rails.root, '/app/assets/images/hipster.jpg'))
109
+ find("form#new_gallery").submit_form!
110
+ end
111
+
112
+ it { should have_content(I18n.t("gallery.success"))}
113
+ it { File.exists? File.join(Rails.root, '/public/uploads/gallery/file/1/thumb_hipster.jpg') }
114
+ end
115
+ end
116
+
117
+ describe "show" do
118
+ let(:gallery) { Factory(:gallery) }
119
+ before do
120
+ visit adminpanel.gallery_path(gallery)
121
+ end
122
+
123
+ it { page.should have_selector("img", :src => gallery.file_url) }
124
+ end
125
125
  end
@@ -1,38 +1,38 @@
1
- require "spec_helper"
2
-
3
- describe "Section pages" do
4
- subject {page}
5
-
6
- let(:user) { Factory(:user) }
7
- before do
8
- visit adminpanel.signin_path
9
- valid_signin(user)
10
- end
11
-
12
- describe "index" do
13
- let(:section) { Factory(:section_with_gallery) }
14
- before do
15
- visit adminpanel.sections_path
16
- end
17
-
18
- it { should have_link("i", adminpanel.section_path(section)) }
19
- it { should have_link("i", adminpanel.edit_section_path(section)) }
20
- end
21
-
22
- describe "show" do
23
- describe "with gallery" do
24
- let(:section) { Factory(:section_with_gallery) }
25
- let(:image) { Factory(:image_section, :foreign_key => section.id) }
26
- # let(:image2) { Factory(:image_section, :foreign_key => section.id) }
27
- # let(:image3) { Factory(:image_section, :foreign_key => section.id) }
28
-
29
- before do
30
- visit adminpanel.section_path(section)
31
- end
32
-
33
- it { should have_title(section.name.humanize) }
34
- it { should have_content(section.description) }
35
- it { should have_link("i", adminpanel.edit_section_path(section)) }
36
- end
37
- end
1
+ require "spec_helper"
2
+
3
+ describe "Section pages" do
4
+ subject {page}
5
+
6
+ let(:user) { Factory(:user) }
7
+ before do
8
+ visit adminpanel.signin_path
9
+ valid_signin(user)
10
+ end
11
+
12
+ describe "index" do
13
+ let(:section) { Factory(:section_with_gallery) }
14
+ before do
15
+ visit adminpanel.sections_path
16
+ end
17
+
18
+ it { should have_link("i", adminpanel.section_path(section)) }
19
+ it { should have_link("i", adminpanel.edit_section_path(section)) }
20
+ end
21
+
22
+ describe "show" do
23
+ describe "with gallery" do
24
+ let(:section) { Factory(:section_with_gallery) }
25
+ let(:image) { Factory(:image_section, :foreign_key => section.id) }
26
+ # let(:image2) { Factory(:image_section, :foreign_key => section.id) }
27
+ # let(:image3) { Factory(:image_section, :foreign_key => section.id) }
28
+
29
+ before do
30
+ visit adminpanel.section_path(section)
31
+ end
32
+
33
+ it { should have_title(section.name.humanize) }
34
+ it { should have_content(section.description) }
35
+ it { should have_link("i", adminpanel.edit_section_path(section)) }
36
+ end
37
+ end
38
38
  end
@@ -1,49 +1,49 @@
1
- require "spec_helper"
2
-
3
- describe "User pages" do
4
- subject {page}
5
-
6
- let(:user) { Factory(:user) }
7
- before do
8
- visit adminpanel.signin_path
9
- valid_signin(user)
10
- end
11
-
12
- describe "index" do
13
- before do
14
- visit adminpanel.users_path
15
- end
16
-
17
- it { should have_link(I18n.t("user.new"), adminpanel.new_user_path)}
18
- it { should have_link("i", adminpanel.user_path(user)) }
19
- it { should have_link("i", adminpanel.edit_user_path(user)) }
20
- end
21
-
22
- describe "new" do
23
- let(:category) { Factory(:category) }
24
- before do
25
- visit adminpanel.new_user_path
26
- end
27
-
28
- it { should have_title(I18n.t("user.new")) }
29
-
30
- describe "with invalid information" do
31
- before { find("form#new_user").submit_form! }
32
-
33
- it { should have_title(I18n.t("user.new")) }
34
- it { should have_selector("div#alerts") }
35
- end
36
-
37
- describe "with valid information" do
38
- before do
39
- fill_in "user_name", :with => "user_name"
40
- fill_in "user_email", :with => "user@example.com"
41
- fill_in "user_password", :with => "123456"
42
- fill_in "user_password_confirmation", :with => "123456"
43
- find("form#new_user").submit_form!
44
- end
45
-
46
- it { should have_content(I18n.t("user.success"))}
47
- end
48
- end
1
+ require "spec_helper"
2
+
3
+ describe "User pages" do
4
+ subject {page}
5
+
6
+ let(:user) { Factory(:user) }
7
+ before do
8
+ visit adminpanel.signin_path
9
+ valid_signin(user)
10
+ end
11
+
12
+ describe "index" do
13
+ before do
14
+ visit adminpanel.users_path
15
+ end
16
+
17
+ it { should have_link(I18n.t("user.new"), adminpanel.new_user_path)}
18
+ it { should have_link("i", adminpanel.user_path(user)) }
19
+ it { should have_link("i", adminpanel.edit_user_path(user)) }
20
+ end
21
+
22
+ describe "new" do
23
+ let(:category) { Factory(:category) }
24
+ before do
25
+ visit adminpanel.new_user_path
26
+ end
27
+
28
+ it { should have_title(I18n.t("user.new")) }
29
+
30
+ describe "with invalid information" do
31
+ before { find("form#new_user").submit_form! }
32
+
33
+ it { should have_title(I18n.t("user.new")) }
34
+ it { should have_selector("div#alerts") }
35
+ end
36
+
37
+ describe "with valid information" do
38
+ before do
39
+ fill_in "user_name", :with => "user_name"
40
+ fill_in "user_email", :with => "user@example.com"
41
+ fill_in "user_password", :with => "123456"
42
+ fill_in "user_password_confirmation", :with => "123456"
43
+ find("form#new_user").submit_form!
44
+ end
45
+
46
+ it { should have_content(I18n.t("user.success"))}
47
+ end
48
+ end
49
49
  end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe "adminpanel:initialize" do
4
+ context "with no arguments or options" do
5
+ it "should generate a migration" do
6
+ subject.should generate("db/migrate/#{Time.now.utc.strftime("%Y%m%d%H%M%S")}_create_adminpanel_tables.rb")
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,122 @@
1
+ require "spec_helper"
2
+
3
+ describe "adminpanel:resource" do
4
+ context "with no arguments or options" do
5
+ it {subject.should generate("db/migrate/#{Time.now.utc.strftime("%Y%m%d%H%M%S")}_create_resources_table.rb")}
6
+ it {subject.should generate("app/models/adminpanel/resource.rb")}
7
+ it {subject.should generate("app/controllers/adminpanel/resources_controller.rb")}
8
+ end
9
+
10
+ with_args :category do
11
+ it "should generate categories migration" do
12
+ subject.should generate("db/migrate/#{Time.now.utc.strftime("%Y%m%d%H%M%S")}_create_categories_table.rb")
13
+ end
14
+ it "should generate categories controller" do
15
+ subject.should generate("app/controllers/adminpanel/categories_controller.rb")
16
+ end
17
+ it "should generate category model" do
18
+ subject.should generate("app/models/adminpanel/category.rb")
19
+ end
20
+ end
21
+
22
+ with_args "Product" do
23
+ with_args :"description:wysiwyg" do
24
+
25
+ it "should generate products migration with attributes" do
26
+ subject.should generate("db/migrate/#{Time.now.utc.strftime("%Y%m%d%H%M%S")}_create_products_table.rb") { |content|
27
+ content.should =~ /t.text \:description/
28
+ }
29
+ end
30
+ end
31
+
32
+ with_args :"long_text:text" do
33
+ it "should generate products migration with attributes" do
34
+ subject.should generate("db/migrate/#{Time.now.utc.strftime("%Y%m%d%H%M%S")}_create_products_table.rb") { |content|
35
+ content.should =~ /t.text \:long_text/
36
+ }
37
+ end
38
+ end
39
+
40
+ with_args :"price:float" do
41
+ it "should generate products migration with attributes" do
42
+ subject.should generate("db/migrate/#{Time.now.utc.strftime("%Y%m%d%H%M%S")}_create_products_table.rb") { |content|
43
+ content.should =~ /t.float \:price/
44
+ }
45
+ end
46
+ end
47
+
48
+ with_args :"date:datepicker" do
49
+ it "should generate products migration with attributes" do
50
+ subject.should generate("db/migrate/#{Time.now.utc.strftime("%Y%m%d%H%M%S")}_create_products_table.rb") { |content|
51
+ content.should =~ /t.string \:date/
52
+ }
53
+ end
54
+ end
55
+
56
+ with_args :"quantity:integer" do
57
+ it "should generate products migration with attributes" do
58
+ subject.should generate("db/migrate/#{Time.now.utc.strftime("%Y%m%d%H%M%S")}_create_products_table.rb") { |content|
59
+ content.should =~ /t.integer \:quantity/
60
+ }
61
+ end
62
+ end
63
+
64
+ with_args :"image:images" do
65
+ it "should generate model with image relationship" do
66
+ subject.should generate("app/models/adminpanel/product.rb") { |content|
67
+ content.should =~ /has_many :images, :foreign_key => "foreign_key", :conditions => \{ :model => "product" \}/
68
+ }
69
+ end
70
+
71
+ it "should accept nested attributes for image" do
72
+ subject.should generate("app/models/adminpanel/product.rb") { |content|
73
+ content.should =~ /accepts_nested_attributes_for :images, :allow_destroy => true/
74
+ }
75
+ end
76
+ end
77
+
78
+ with_args "name:string" do
79
+ it "should generate products migration with attributes" do
80
+ subject.should generate("db/migrate/#{Time.now.utc.strftime("%Y%m%d%H%M%S")}_create_products_table.rb") { |content|
81
+ content.should =~ /t.string \:name/
82
+ }
83
+ end
84
+ end
85
+
86
+ with_args :"name:string", :"description:wysiwyg" do
87
+ it "should generate namespaced products_controller.rb" do
88
+ subject.should generate("app/controllers/adminpanel/products_controller.rb") { |content|
89
+ content.should ==
90
+ "module Adminpanel
91
+ class ProductsController < Adminpanel::ApplicationController
92
+ end
93
+ end"
94
+ }
95
+ end
96
+
97
+ it "should generate model with attr_accessible" do
98
+ subject.should generate("app/models/adminpanel/product.rb") { |content|
99
+ content.should =~ /attr_accessible/
100
+ }
101
+ end
102
+
103
+ it "should generate model with description hash" do
104
+ subject.should generate("app/models/adminpanel/product.rb") { |content|
105
+ content.should =~ /\{\"description\" => \{\"type\" => \"wysiwyg_field\", \"name\" => \"description\", \"label\" => \"description\", \"placeholder\" => \"description\"\}\}/
106
+ }
107
+ end
108
+
109
+ it "should generate model with name hash" do
110
+ subject.should generate("app/models/adminpanel/product.rb") { |content|
111
+ content.should =~ /\{\"name\" => \{\"type\" => \"text_field\", \"name\" => \"name\", \"label\" => \"name\", \"placeholder\" => \"name\"\}\}/
112
+ }
113
+ end
114
+
115
+ it "should generate model with overwritten sample_name" do
116
+ subject.should generate("app/models/adminpanel/product.rb") { |content|
117
+ content.should =~ /def self.display_name\n \"Product\"\n end/
118
+ }
119
+ end
120
+ end
121
+ end
122
+ end