adminpanel 1.2.12 → 2.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.
- checksums.yaml +7 -0
- data/.travis.yml +3 -4
- data/Gemfile +22 -20
- data/README.md +12 -9
- data/adminpanel.gemspec +29 -28
- data/app/assets/fonts/.keep +0 -0
- data/app/assets/javascripts/adminpanel/images_form.js +5 -2
- data/app/assets/javascripts/adminpanel/imagesloaded.js +5 -2
- data/app/assets/javascripts/adminpanel/tables.js +6 -3
- data/app/assets/javascripts/application-admin.js +2 -1
- data/app/assets/stylesheets/adminpanel/{_clearfix.css.scss → _clearfix.css} +0 -0
- data/app/assets/stylesheets/adminpanel/bootstrap.css +2 -2
- data/app/assets/stylesheets/adminpanel/medium-editor.css.scss +1 -1
- data/app/assets/stylesheets/application-admin.css +2 -1
- data/app/controllers/adminpanel/application_controller.rb +28 -21
- data/app/controllers/adminpanel/categories_controller.rb +16 -5
- data/app/controllers/adminpanel/galleries_controller.rb +11 -5
- data/app/controllers/adminpanel/sections_controller.rb +14 -0
- data/app/controllers/adminpanel/users_controller.rb +10 -80
- data/app/controllers/concerns/adminpanel/galleryzable_actions.rb +33 -0
- data/app/controllers/concerns/adminpanel/rest_actions.rb +109 -0
- data/app/helpers/adminpanel/application_helper.rb +0 -1
- data/app/helpers/adminpanel/custom_form_builder.rb +12 -13
- data/app/helpers/adminpanel/router_helper.rb +11 -2
- data/app/helpers/adminpanel/shared_pages_helper.rb +0 -1
- data/app/models/adminpanel/analytic.rb +3 -2
- data/app/models/adminpanel/gallery.rb +8 -4
- data/app/models/adminpanel/group.rb +1 -1
- data/app/models/adminpanel/image.rb +1 -2
- data/app/models/adminpanel/section.rb +19 -10
- data/app/models/adminpanel/user.rb +11 -3
- data/app/models/concerns/adminpanel/base.rb +149 -0
- data/app/models/concerns/adminpanel/galleryzation.rb +66 -0
- data/app/models/contact.rb +16 -9
- data/app/views/adminpanel/analytics/index.html.erb +2 -1
- data/app/views/adminpanel/categories/_categories_table.html.erb +6 -7
- data/app/views/adminpanel/categories/_category_form.html.erb +2 -2
- data/app/views/adminpanel/categories/create.js.erb +2 -2
- data/app/views/adminpanel/categories/index.html.erb +1 -1
- data/app/views/adminpanel/galleries/_galleries_table.html.erb +7 -7
- data/app/views/adminpanel/galleries/index.html.erb +6 -5
- data/app/views/adminpanel/sections/_sections_table.html.erb +2 -2
- data/app/views/adminpanel/sections/edit.html.erb +5 -3
- data/app/views/adminpanel/sections/show.html.erb +3 -3
- data/app/views/adminpanel/sessions/new.html.erb +1 -1
- data/app/views/layouts/_side_menu.html.erb +2 -2
- data/app/views/layouts/_top_bar.html.erb +3 -3
- data/app/views/layouts/admin-login.html.erb +0 -1
- data/app/views/layouts/admin.html.erb +3 -3
- data/app/views/shared/_delete_icon_button.html.erb +16 -0
- data/app/views/shared/_edit_icon_button.html.erb +14 -0
- data/app/views/shared/_error_messages.html.erb +1 -1
- data/app/views/shared/_form_fields.html.erb +15 -13
- data/app/views/shared/_gallery_entries.html.erb +2 -2
- data/app/views/shared/_init_editor.html.erb +5 -2
- data/app/views/shared/_new_resource_button.html.erb +18 -0
- data/app/views/shared/_remote_form_fields.html.erb +1 -1
- data/app/views/shared/_show_icon_button.html.erb +14 -0
- data/app/views/shared/edit.html.erb +3 -3
- data/app/views/shared/index.html.erb +13 -48
- data/app/views/shared/new.html.erb +3 -3
- data/app/views/shared/show.html.erb +5 -5
- data/config/initializers/pluralization_es.rb +16 -0
- data/config/locales/en.yml +89 -0
- data/config/locales/es.yml +4 -4
- data/config/routes.rb +15 -16
- data/lib/adminpanel.rb +8 -8
- data/lib/adminpanel/version.rb +1 -1
- data/lib/generators/adminpanel/gallery/gallery_generator.rb +12 -8
- data/lib/generators/adminpanel/gallery/templates/gallery_template.rb +2 -3
- data/lib/generators/adminpanel/initialize/templates/category_template.rb +2 -3
- data/lib/generators/adminpanel/resource/resource_generator.rb +24 -18
- data/lib/generators/adminpanel/resource/templates/controller.rb +5 -0
- data/lib/generators/adminpanel/resource/templates/resource.rb +3 -3
- data/lib/tasks/adminpanel/adminpanel.rake +43 -90
- data/spec/dummy/app/controllers/adminpanel/mugs_controller.rb +9 -0
- data/spec/dummy/app/controllers/adminpanel/products_controller.rb +12 -0
- data/spec/dummy/app/models/ability.rb +1 -1
- data/spec/dummy/app/models/adminpanel/categorization.rb +1 -2
- data/spec/dummy/app/models/adminpanel/category.rb +18 -19
- data/spec/dummy/app/models/adminpanel/mug.rb +37 -0
- data/spec/dummy/app/models/adminpanel/photo.rb +3 -3
- data/spec/dummy/app/models/adminpanel/product.rb +2 -2
- data/spec/dummy/config/application.rb +2 -11
- data/spec/dummy/config/database.yml +0 -6
- data/spec/dummy/config/environments/development.rb +11 -23
- data/spec/dummy/config/environments/production.rb +40 -32
- data/spec/dummy/config/environments/test.rb +13 -18
- data/spec/dummy/config/initializers/adminpanel_setup.rb +2 -1
- data/spec/dummy/config/locales/.keep +0 -0
- data/spec/dummy/db/schema.rb +68 -2
- data/spec/features/authentication_pages_spec.rb +15 -15
- data/spec/features/galleries_pages_spec.rb +30 -22
- data/spec/features/section_pages_spec.rb +15 -18
- data/spec/features/shared_pages_spec.rb +97 -127
- data/spec/generators/gallery_generator_spec.rb +2 -3
- data/spec/generators/resource_generator_spec.rb +20 -3
- data/spec/models/gallery_spec.rb +2 -2
- data/spec/models/section_spec.rb +8 -15
- data/spec/models/user_spec.rb +23 -39
- data/spec/spec_helper.rb +9 -1
- data/spec/support/factories.rb +52 -0
- data/spec/support/helper_methods.rb +25 -5
- data/spec/tasks/adminpanel_rake_spec.rb +11 -10
- metadata +361 -353
- data/app/assets/fonts/FontAwesome.otf +0 -0
- data/app/assets/fonts/fontawesome-webfont.eot +0 -0
- data/app/assets/fonts/fontawesome-webfont.svg +0 -255
- data/app/assets/fonts/fontawesome-webfont.ttf +0 -0
- data/app/assets/fonts/fontawesome-webfont.woff +0 -0
- data/app/assets/stylesheets/adminpanel/colorpicker.css +0 -7
- data/app/assets/stylesheets/adminpanel/elfinder.min.css +0 -59
- data/app/assets/stylesheets/adminpanel/font-awesome.min.css +0 -34
- data/app/helpers/adminpanel/pluralizations_helper.rb +0 -25
- data/app/helpers/adminpanel/rest_actions_helper.rb +0 -128
- data/app/views/adminpanel/galleries/delete.html.erb +0 -2
- data/app/views/adminpanel/galleries/edit.html.erb +0 -19
- data/app/views/adminpanel/galleries/new.html.erb +0 -18
- data/app/views/adminpanel/galleries/show.html.erb +0 -18
- data/app/views/adminpanel/galleries/update.html.erb +0 -2
- data/lib/adminpanel/active_record/adminpanel_extension.rb +0 -187
- data/spec/dummy/config/locales/en.yml +0 -5
- data/spec/support/define_factory_models.rb +0 -45
- data/spec/support/submit_forms_without_button.rb +0 -17
- data/spec/support/test_database.rb +0 -76
- data/spec/uploaders/gallery_uploader_spec.rb +0 -37
- data/spec/uploaders/image_uploader_spec.rb +0 -31
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
<% provide(:page_title, "Editar") %>
|
|
2
|
-
<% breadcrumb_add(t("model.Gallery"), galleries_path) %>
|
|
3
|
-
<% breadcrumb_add('Imagen', gallery_path(@gallery)) %>
|
|
4
|
-
<div class="row-fluid">
|
|
5
|
-
<div class = "widget widget-padding span12">
|
|
6
|
-
<div class = "widget-header"><i class = "icon-picture"></i><h5>Imagen</h5></div>
|
|
7
|
-
<div class = "widget-body">
|
|
8
|
-
<div class = "widget-forms clearfix">
|
|
9
|
-
<%= custom_form_for(@gallery, :url => gallery_path(@gallery), :html => {:class => "form-horizontal"}) do |f| %>
|
|
10
|
-
<%= render 'shared/error_messages', :object => @gallery %>
|
|
11
|
-
<%= f.gallery_field :file %>
|
|
12
|
-
</div>
|
|
13
|
-
</div>
|
|
14
|
-
<div class = "widget-footer">
|
|
15
|
-
<%= f.submit "Agregar", :disable_with => 'Submiting...' %>
|
|
16
|
-
</div>
|
|
17
|
-
<% end -%>
|
|
18
|
-
</div>
|
|
19
|
-
</div>
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
<% provide(:page_title, t("gallery.new")) %>
|
|
2
|
-
<% breadcrumb_add(t("model.Gallery"), galleries_path) %>
|
|
3
|
-
<div class="row-fluid">
|
|
4
|
-
<div class = "widget widget-padding span12">
|
|
5
|
-
<div class = "widget-header"><i class = "icon-picture"></i><h5>Imagen</h5></div>
|
|
6
|
-
<div class = "widget-body">
|
|
7
|
-
<div class = "widget-forms clearfix">
|
|
8
|
-
<%= custom_form_for(@gallery, :url => galleries_path, :html => {:class => "form-horizontal"}) do |f| %>
|
|
9
|
-
<%= render 'shared/error_messages', :object => @gallery %>
|
|
10
|
-
<%= f.file_field :file, :label => "Imagen" -%>
|
|
11
|
-
</div>
|
|
12
|
-
</div>
|
|
13
|
-
<div class = "widget-footer">
|
|
14
|
-
<%= f.submit t("gallery.new"), :disable_with => 'Submiting...' %>
|
|
15
|
-
</div>
|
|
16
|
-
<% end -%>
|
|
17
|
-
</div>
|
|
18
|
-
</div>
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
<% provide(:page_title, 'Galeria de Inicio') %>
|
|
2
|
-
<% breadcrumb_add(t("Gallery"), galleries_path) %>
|
|
3
|
-
|
|
4
|
-
<div class="row-fluid">
|
|
5
|
-
<div class="widget widget-padding span12">
|
|
6
|
-
<div class="widget-header">
|
|
7
|
-
<i class="icon-picture"></i>
|
|
8
|
-
<h5>Galería de inicio
|
|
9
|
-
<%= link_to content_tag(:i, nil, :class => 'icon-pencil'), edit_gallery_path(@gallery), :title => "Editar Producto" %>
|
|
10
|
-
</h5>
|
|
11
|
-
</div>
|
|
12
|
-
<div class="widget-body row-fluid">
|
|
13
|
-
<div class="span12">
|
|
14
|
-
<%= image_tag @gallery.file_url %>
|
|
15
|
-
</div>
|
|
16
|
-
</div>
|
|
17
|
-
</div>
|
|
18
|
-
</div>
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
module ActiveRecord
|
|
2
|
-
module AdminpanelExtension
|
|
3
|
-
extend ActiveSupport::Concern
|
|
4
|
-
#instance methods
|
|
5
|
-
def move_to_better_position
|
|
6
|
-
if self.position > 1
|
|
7
|
-
conflicting_gallery = self.class.where(self.class.relation_field => self.send(self.class.relation_field)).find_by_position(position - 1)
|
|
8
|
-
self.update_attribute(:position, self.position - 1)
|
|
9
|
-
conflicting_gallery.update_attribute(
|
|
10
|
-
:position, conflicting_gallery.position + 1
|
|
11
|
-
)
|
|
12
|
-
true
|
|
13
|
-
else
|
|
14
|
-
false
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def move_to_worst_position
|
|
19
|
-
records = self.class.count
|
|
20
|
-
if self.position < records
|
|
21
|
-
conflicting_gallery = self.class.where(self.class.relation_field => self.send(self.class.relation_field)).find_by_position(position + 1)
|
|
22
|
-
update_attribute(:position, self.position + 1)
|
|
23
|
-
conflicting_gallery.update_attribute(
|
|
24
|
-
:position, conflicting_gallery.position - 1
|
|
25
|
-
)
|
|
26
|
-
true
|
|
27
|
-
else
|
|
28
|
-
false
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
# static(class) methods
|
|
33
|
-
module ClassMethods
|
|
34
|
-
def mount_images(relation)
|
|
35
|
-
has_many relation, :dependent => :destroy
|
|
36
|
-
accepts_nested_attributes_for relation, :allow_destroy => true
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def act_as_a_gallery
|
|
40
|
-
before_create :set_position
|
|
41
|
-
before_destroy :rearrange_positions
|
|
42
|
-
|
|
43
|
-
default_scope { order("position ASC")}
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def form_attributes
|
|
47
|
-
[{
|
|
48
|
-
"name" => {
|
|
49
|
-
"type" => "text_field",
|
|
50
|
-
"label" => "name"
|
|
51
|
-
}
|
|
52
|
-
}]
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def display_name
|
|
56
|
-
"display_name"
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def get_attribute_name(field)
|
|
60
|
-
form_attributes.each do |attribute|
|
|
61
|
-
attribute.each do |name, properties|
|
|
62
|
-
if name == field
|
|
63
|
-
return properties["label"]
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
return ":("
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def get_attribute_label(field)
|
|
71
|
-
form_attributes.each do |attribute|
|
|
72
|
-
attribute.each do |name, properties|
|
|
73
|
-
if name == field
|
|
74
|
-
return properties["label"]
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
return ":("
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
def get_attribute_placeholder(field)
|
|
82
|
-
form_attributes.each do |attribute|
|
|
83
|
-
attribute.each do |name, properties|
|
|
84
|
-
if name == field
|
|
85
|
-
return properties["placeholder"]
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
return ":("
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
def display_attributes(type)
|
|
93
|
-
display_attributes = []
|
|
94
|
-
form_attributes.each do |attribute|
|
|
95
|
-
attribute.each do |name, properties|
|
|
96
|
-
if properties['show'].nil? ||
|
|
97
|
-
properties['show'] == 'true' ||
|
|
98
|
-
properties['show'] == type
|
|
99
|
-
display_attributes << attribute
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
return display_attributes
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
def has_images?
|
|
108
|
-
form_attributes.each do |fields|
|
|
109
|
-
fields.each do |attribute, properties|
|
|
110
|
-
if properties["type"] == "adminpanel_file_field"
|
|
111
|
-
return true
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
return false
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
def get_image_relationship
|
|
119
|
-
form_attributes.each do |fields|
|
|
120
|
-
fields.each do |attribute, properties|
|
|
121
|
-
if properties["type"] == "adminpanel_file_field"
|
|
122
|
-
return attribute
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
end
|
|
126
|
-
return false
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
def belongs_to_relationships
|
|
130
|
-
belongs_to_classes = []
|
|
131
|
-
form_attributes.each do |fields|
|
|
132
|
-
fields.each do |attribute, properties|
|
|
133
|
-
if properties["type"] == "belongs_to"
|
|
134
|
-
belongs_to_classes << properties["model"].classify.constantize
|
|
135
|
-
end
|
|
136
|
-
end
|
|
137
|
-
end
|
|
138
|
-
return belongs_to_classes
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
def has_many_relationships
|
|
142
|
-
has_many_classes = []
|
|
143
|
-
form_attributes.each do |fields|
|
|
144
|
-
fields.each do |attribute, properties|
|
|
145
|
-
if properties["type"] == "has_many"
|
|
146
|
-
has_many_classes << properties["model"].classify.constantize
|
|
147
|
-
end
|
|
148
|
-
end
|
|
149
|
-
end
|
|
150
|
-
return has_many_classes
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
def icon
|
|
154
|
-
"icon-truck"
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
def act_as_a_gallery?
|
|
158
|
-
nil
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
def self.relation_field
|
|
162
|
-
'undefined_relation_field'
|
|
163
|
-
end
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
private
|
|
167
|
-
def rearrange_positions
|
|
168
|
-
unarranged_galleries = self.class.where(self.class.relation_field => self.send(self.class.relation_field)).where("position > ?", self.position)
|
|
169
|
-
unarranged_galleries.each do |gallery|
|
|
170
|
-
gallery.update_attribute(:position, gallery.position - 1)
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
def set_position
|
|
176
|
-
last_record = self.class.where(self.class.relation_field => self.send(self.class.relation_field)).last
|
|
177
|
-
if last_record.nil?
|
|
178
|
-
self.position = 1
|
|
179
|
-
else
|
|
180
|
-
self.position = last_record.position + 1
|
|
181
|
-
end
|
|
182
|
-
end
|
|
183
|
-
|
|
184
|
-
end
|
|
185
|
-
# include the extension
|
|
186
|
-
ActiveRecord::Base.send(:include, AdminpanelExtension)
|
|
187
|
-
end
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
include ActionDispatch::TestProcess
|
|
2
|
-
|
|
3
|
-
Factory.define :user, :class => Adminpanel::User do |user|
|
|
4
|
-
user.name "test user"
|
|
5
|
-
user.email "email@test.com"
|
|
6
|
-
user.password "123456"
|
|
7
|
-
user.password_confirmation "123456"
|
|
8
|
-
user.group_id '1'
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
Factory.define :group, :class => Adminpanel::Group do |group|
|
|
12
|
-
group.name 'Admin'
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
Factory.define :gallery, :class => Adminpanel::Gallery do |gallery|
|
|
16
|
-
gallery.file { fixture_file_upload(Rails.root.join('app', 'assets', 'images', 'hipster.jpg'), 'image/jpeg') }
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
Factory.define :image_section, :class => Adminpanel::Image do |image|
|
|
20
|
-
image.file { fixture_file_upload(Rails.root.join('app', 'assets', 'images', 'hipster.jpg'), 'image/jpeg') }
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
Factory.define :product, :class => Adminpanel::Product do |product|
|
|
24
|
-
product.price "12392.2"
|
|
25
|
-
product.name "very little description"
|
|
26
|
-
product.description "this is a little longer description, can be very long"
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
Factory.define :category, :class => Adminpanel::Category do |category|
|
|
30
|
-
category.name "Test Category"
|
|
31
|
-
category.model "Product"
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
Factory.define :photo, :class => Adminpanel::Photo do |photo|
|
|
35
|
-
photo.file { fixture_file_upload(Rails.root.join('app', 'assets', 'images', 'hipster.jpg'), 'image/jpeg') }
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
Factory.define :section_with_gallery, :class => Adminpanel::Section do |section|
|
|
39
|
-
section.key "key"
|
|
40
|
-
# section.description "<p>description</p>"
|
|
41
|
-
section.has_image true
|
|
42
|
-
section.has_description false
|
|
43
|
-
section.name "section_name"
|
|
44
|
-
section.page "index"
|
|
45
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
class Capybara::Driver::Node
|
|
2
|
-
def submit_form!
|
|
3
|
-
raise NotImplementedError
|
|
4
|
-
end
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
class Capybara::RackTest::Node
|
|
8
|
-
def submit_form!
|
|
9
|
-
Capybara::RackTest::Form.new(driver, self.native).submit({})
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
class Capybara::Node::Element
|
|
14
|
-
def submit_form!
|
|
15
|
-
wait_until { base.submit_form! }
|
|
16
|
-
end
|
|
17
|
-
end
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
ActiveRecord::Migration.create_table :adminpanel_users do |t|
|
|
2
|
-
t.string :name
|
|
3
|
-
t.string :email
|
|
4
|
-
t.string :password_digest
|
|
5
|
-
t.string :remember_token
|
|
6
|
-
t.integer :group_id
|
|
7
|
-
t.datetime :created_at, :null => false
|
|
8
|
-
t.datetime :updated_at, :null => false
|
|
9
|
-
end
|
|
10
|
-
ActiveRecord::Migration.create_table :adminpanel_galleries do |t|
|
|
11
|
-
t.string :file
|
|
12
|
-
t.integer :position
|
|
13
|
-
t.datetime :created_at, :null => false
|
|
14
|
-
t.datetime :updated_at, :null => false
|
|
15
|
-
end
|
|
16
|
-
ActiveRecord::Migration.create_table :adminpanel_images do |t|
|
|
17
|
-
t.string :file
|
|
18
|
-
t.string :section_id
|
|
19
|
-
t.datetime :created_at, :null => false
|
|
20
|
-
t.datetime :updated_at, :null => false
|
|
21
|
-
end
|
|
22
|
-
ActiveRecord::Migration.create_table :adminpanel_products do |t|
|
|
23
|
-
t.string :price
|
|
24
|
-
t.string :name
|
|
25
|
-
t.text :description
|
|
26
|
-
t.datetime :created_at, :null => false
|
|
27
|
-
t.datetime :updated_at, :null => false
|
|
28
|
-
end
|
|
29
|
-
ActiveRecord::Migration.create_table :adminpanel_photos do |t|
|
|
30
|
-
t.string :file
|
|
31
|
-
t.text :product_id
|
|
32
|
-
t.datetime :created_at, :null => false
|
|
33
|
-
t.datetime :updated_at, :null => false
|
|
34
|
-
end
|
|
35
|
-
ActiveRecord::Migration.create_table :adminpanel_categories do |t|
|
|
36
|
-
t.string :name
|
|
37
|
-
t.string :model
|
|
38
|
-
t.datetime :created_at, :null => false
|
|
39
|
-
t.datetime :updated_at, :null => false
|
|
40
|
-
end
|
|
41
|
-
ActiveRecord::Migration.create_table :adminpanel_categorizations do |t|
|
|
42
|
-
t.integer :product_id
|
|
43
|
-
t.integer :category_id
|
|
44
|
-
t.datetime :created_at, :null => false
|
|
45
|
-
t.datetime :updated_at, :null => false
|
|
46
|
-
end
|
|
47
|
-
ActiveRecord::Migration.create_table :adminpanel_groups do |t|
|
|
48
|
-
t.string :name
|
|
49
|
-
t.datetime :created_at, :null => false
|
|
50
|
-
t.datetime :updated_at, :null => false
|
|
51
|
-
end
|
|
52
|
-
ActiveRecord::Migration.create_table :adminpanel_sections do |t|
|
|
53
|
-
t.string :name
|
|
54
|
-
t.text :description
|
|
55
|
-
t.string :key
|
|
56
|
-
t.boolean :has_image
|
|
57
|
-
t.string :page
|
|
58
|
-
t.datetime :created_at, :null => false
|
|
59
|
-
t.datetime :updated_at, :null => false
|
|
60
|
-
t.boolean :has_description
|
|
61
|
-
end
|
|
62
|
-
module ActiveModel::Validations
|
|
63
|
-
def errors_on(attribute)
|
|
64
|
-
self.valid?
|
|
65
|
-
[self.errors[attribute]].flatten.compact
|
|
66
|
-
end
|
|
67
|
-
alias :error_on :errors_on
|
|
68
|
-
end
|
|
69
|
-
RSpec.configure do |config|
|
|
70
|
-
config.around do |example|
|
|
71
|
-
ActiveRecord::Base.transaction do
|
|
72
|
-
example.run
|
|
73
|
-
raise ActiveRecord::Rollback
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
end
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'support/test_database'
|
|
3
|
-
require 'carrierwave/test/matchers'
|
|
4
|
-
|
|
5
|
-
describe Adminpanel::GalleryUploader do
|
|
6
|
-
include CarrierWave::Test::Matchers
|
|
7
|
-
|
|
8
|
-
before do
|
|
9
|
-
Adminpanel::GalleryUploader.enable_processing = true
|
|
10
|
-
@gallery = Adminpanel::Gallery.new(:file => "test.jpg")
|
|
11
|
-
@gallery_uploader = Adminpanel::GalleryUploader.new(@gallery, :file)
|
|
12
|
-
@gallery_uploader.store!(File.open(Rails.root + "app/assets/images/hipster.jpg"))
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
context 'the gallery.thumb version' do
|
|
17
|
-
it "should scale down a landscape image to be exactly 200 by 200 pixels" do
|
|
18
|
-
@gallery_uploader.thumb.should be_no_larger_than(200, 200)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
after do
|
|
22
|
-
Adminpanel::GalleryUploader.enable_processing = false
|
|
23
|
-
@gallery_uploader.remove!
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
context 'the gallery.default version' do
|
|
28
|
-
it "should scale down a landscape image to fit within 1024 by 450 pixels" do
|
|
29
|
-
@gallery_uploader.should have_dimensions(1024, 450)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
after do
|
|
33
|
-
Adminpanel::GalleryUploader.enable_processing = false
|
|
34
|
-
@gallery_uploader.remove!
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'carrierwave/test/matchers'
|
|
3
|
-
|
|
4
|
-
describe Adminpanel::ImageUploader do
|
|
5
|
-
include CarrierWave::Test::Matchers
|
|
6
|
-
|
|
7
|
-
before do
|
|
8
|
-
Adminpanel::ImageUploader.enable_processing = true
|
|
9
|
-
@image = Adminpanel::Image.new(:file => "test.jpg")
|
|
10
|
-
@image_uploader = Adminpanel::ImageUploader.new(@image, :file)
|
|
11
|
-
@image_uploader.store!(File.open(Rails.root + "app/assets/images/test.jpg"))
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
context 'the thumb version' do
|
|
16
|
-
it "should scale down a landscape image to be exactly 220 by 220 pixels" do
|
|
17
|
-
@image_uploader.thumb.should be_no_larger_than(220, 220)
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
context 'the porfolio version' do
|
|
22
|
-
it "should scale down a landscape image to be exactly 468 by 312 pixels" do
|
|
23
|
-
@image_uploader.portfolio.should be_no_larger_than(468, 312)
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
after do
|
|
28
|
-
Adminpanel::ImageUploader.enable_processing = false
|
|
29
|
-
@image_uploader.remove!
|
|
30
|
-
end
|
|
31
|
-
end
|