redde 0.1.10 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.travis.yml +2 -3
- data/lib/generators/redde/layout/layout_generator.rb +22 -1
- data/lib/generators/redde/layout/templates/base/_header.html.haml +1 -1
- data/lib/generators/redde/layout/templates/base/_launchbar.html.haml +2 -2
- data/lib/generators/redde/layout/templates/base/_sidebar.html.haml +3 -4
- data/lib/generators/redde/layout/templates/controllers/base_controller.rb +19 -2
- data/lib/generators/redde/layout/templates/controllers/managers/registrations_controller.rb +21 -0
- data/lib/generators/redde/layout/templates/controllers/managers_controller.rb +30 -0
- data/lib/generators/redde/photo/templates/photo.rb +1 -4
- data/lib/generators/redde/photo/templates/uploader.rb +0 -4
- data/lib/generators/redde/scaffold/templates/controllers/controller.rb +6 -14
- data/lib/redde/concerns/photoable.rb +17 -0
- data/lib/redde/concerns/with_photo.rb +17 -3
- data/lib/redde/version.rb +1 -1
- data/lib/redde.rb +1 -0
- data/redde.gemspec +9 -9
- data/spec/dummy/app/models/article.rb +1 -0
- data/spec/dummy/app/models/photo.rb +3 -0
- data/spec/dummy/app/views/admin/photos/_photo.haml +5 -0
- data/spec/dummy/app/views/admin/photos/_photos.haml +19 -0
- data/spec/dummy/app/views/admin/photos/create.js.erb +1 -0
- data/spec/dummy/app/views/admin/photos/destroy.js.erb +1 -0
- data/spec/dummy/db/migrate/20140607122532_create_photos.rb +16 -0
- data/spec/dummy/db/schema.rb +70 -1
- data/spec/generators/layout_generator_spec.rb +16 -18
- data/spec/generators/photo_generator_spec.rb +11 -12
- data/spec/generators/scaffold_generator_spec.rb +25 -26
- data/spec/models/sluggable_spec.rb +0 -1
- data/spec/models/with_photo_spec.rb +25 -0
- data/spec/spec_helper.rb +7 -14
- metadata +19 -6
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7db06e9218ae6343bcc14a2dd7f22680b620750
|
4
|
+
data.tar.gz: eef951c975ae0d16d8e0d83fd08499b06ead764e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cc6de724a9a269574ee2b76032544283f8ef49e159ddb82f71fc45d6cf0d497ef2d82d44d0f005f1a3f489926ee2f4f03397c4a4528ddc079e2f6fbc888b724
|
7
|
+
data.tar.gz: cbb28953633ae2aae37658fa38c510dbd5ada7026819642e2ee5ef84be3b8259198d36ecda581ab7c2068442e5b41f027cbb6a4aac780626b0d26baca0f65892
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -8,20 +8,41 @@ module Redde
|
|
8
8
|
|
9
9
|
attr_reader :app_name
|
10
10
|
|
11
|
-
def
|
11
|
+
def make_views
|
12
12
|
%w(admin login).each do |layout|
|
13
13
|
template "layouts/#{layout}#{ext}", "app/views/layouts/#{layout}#{ext}"
|
14
14
|
end
|
15
15
|
directory 'base', 'app/views/admin/base'
|
16
|
+
end
|
17
|
+
|
18
|
+
def make_js
|
16
19
|
%w(admin.js).each do |js|
|
17
20
|
template "assets/javascripts/#{js}", "app/assets/javascripts/#{js}"
|
18
21
|
end
|
19
22
|
directory 'assets/javascripts/admin', 'app/assets/javascripts/admin'
|
23
|
+
end
|
24
|
+
|
25
|
+
def make_css
|
20
26
|
directory 'assets/stylesheets/admin', 'app/assets/stylesheets/admin'
|
21
27
|
directory 'assets/redactor', 'app/assets'
|
28
|
+
end
|
29
|
+
|
30
|
+
def make_helpers
|
22
31
|
template 'helpers/admin_helper.rb', 'app/helpers/admin_helper.rb'
|
32
|
+
end
|
33
|
+
|
34
|
+
def make_images
|
23
35
|
directory 'assets/images/admin', 'app/assets/images/admin'
|
36
|
+
end
|
37
|
+
|
38
|
+
def make_controllers
|
24
39
|
template 'controllers/base_controller.rb', 'app/controllers/admin/base_controller.rb'
|
40
|
+
template 'controllers/managers_controller.rb', 'app/controllers/admin/managers_controller.rb'
|
41
|
+
directory 'controllers/managers', 'app/controllers/managers'
|
42
|
+
end
|
43
|
+
|
44
|
+
def fix_routes
|
45
|
+
route("devise_for :managers, controllers: { registrations: 'managers/registrations' }")
|
25
46
|
end
|
26
47
|
|
27
48
|
private
|
@@ -1,11 +1,11 @@
|
|
1
1
|
- case controller_name
|
2
2
|
- when 'products' then @active = :shop
|
3
3
|
- when 'articles' then @active = :materials
|
4
|
-
- when 'users' then @active = :system
|
4
|
+
- when 'users', 'managers' then @active = :system
|
5
5
|
|
6
6
|
.launchbar
|
7
7
|
%nav.launchbar__menu
|
8
8
|
= link_to 'Материалы', nil, class: ['launchbar__link', ('_active' if @active == :shop)]
|
9
9
|
= link_to 'Обратная связь', nil, class: ['launchbar__link', ('_active' if @active == :materials)]
|
10
|
-
= link_to 'Система',
|
10
|
+
= link_to 'Система', [:admin, :managers], class: ['launchbar__link', ('_active' if @active == :system)]
|
11
11
|
%span.launchbar__time= Russian.strftime(Time.now, '%d %b, %Y %H:%M ')
|
@@ -1,13 +1,12 @@
|
|
1
|
-
-# add this condition to remove empty sidebar
|
2
|
-
-# if @active
|
3
1
|
%nav.sidebar
|
4
2
|
- case @active
|
5
3
|
- when :shop
|
6
|
-
= link_to 'Товары',
|
4
|
+
= link_to 'Товары', [:admin, :products], class: 'sidebar__link'
|
7
5
|
- when :materials
|
8
6
|
= link_to 'Статьи', [:admin, :articles], class: 'sidebar__link'
|
9
7
|
- when :system
|
10
|
-
= link_to '
|
8
|
+
= link_to 'Администраторы', [:admin, :managers], class: 'sidebar__link'
|
9
|
+
= link_to 'Пользователи', [:admin, :users], class: 'sidebar__link'
|
11
10
|
- else
|
12
11
|
= link_to 'Демо active', nil, class: ['sidebar__link', '_active']
|
13
12
|
= link_to nil, class: ['sidebar__link'] do
|
@@ -1,5 +1,3 @@
|
|
1
|
-
#coding: utf-8
|
2
|
-
|
3
1
|
class Admin::BaseController < ActionController::Base
|
4
2
|
layout 'admin'
|
5
3
|
before_filter :authenticate_manager!
|
@@ -7,4 +5,23 @@ class Admin::BaseController < ActionController::Base
|
|
7
5
|
|
8
6
|
def welcome
|
9
7
|
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def redirect_or_edit(obj, saved)
|
12
|
+
if saved
|
13
|
+
redirect_to url_for_obj(obj), notice: notice_for(obj)
|
14
|
+
else
|
15
|
+
render 'edit'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def notice_for(obj)
|
20
|
+
"#{obj.class.model_name.human} сохранен."
|
21
|
+
end
|
22
|
+
|
23
|
+
def url_for_obj(obj)
|
24
|
+
return [:edit, :admin, obj] if params[:commit] == 'Применить'
|
25
|
+
[:admin, obj.class.model_name.plural.to_sym]
|
26
|
+
end
|
10
27
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Managers::RegistrationsController < Devise::RegistrationsController
|
2
|
+
def new
|
3
|
+
redirect_to root_path, alert: 'Регистрация закрыта'
|
4
|
+
end
|
5
|
+
|
6
|
+
def create
|
7
|
+
redirect_to root_path, alert: 'Регистрация закрыта'
|
8
|
+
end
|
9
|
+
|
10
|
+
def edit
|
11
|
+
redirect_to root_path, alert: 'Регистрация закрыта'
|
12
|
+
end
|
13
|
+
|
14
|
+
def update
|
15
|
+
redirect_to root_path, alert: 'Регистрация закрыта'
|
16
|
+
end
|
17
|
+
|
18
|
+
def destroy
|
19
|
+
redirect_to root_path, alert: 'Регистрация закрыта'
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class Admin::ManagersController < Admin::BaseController
|
2
|
+
def index
|
3
|
+
@managers = Manager.all
|
4
|
+
end
|
5
|
+
|
6
|
+
def new
|
7
|
+
@manager = Manager.new
|
8
|
+
render 'edit'
|
9
|
+
end
|
10
|
+
|
11
|
+
def create
|
12
|
+
@manager = Manager.new(manager_params)
|
13
|
+
redirect_or_edit(@manager, @manager.save)
|
14
|
+
end
|
15
|
+
|
16
|
+
def edit
|
17
|
+
@manager = Manager.find(params[:id])
|
18
|
+
end
|
19
|
+
|
20
|
+
def update
|
21
|
+
@manager = Manager.find(params[:id])
|
22
|
+
redirect_or_edit(@manager, @manager.update(manager_params))
|
23
|
+
end
|
24
|
+
|
25
|
+
def destroy
|
26
|
+
@manager = Manager.find(params[:id])
|
27
|
+
@manager.destroy if current_manager.id != @manager.id
|
28
|
+
redirect_to [:admin, :managers], alert: 'Администратор удален'
|
29
|
+
end
|
30
|
+
end
|
@@ -1,7 +1,4 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
class PhotoUploader < CarrierWave::Uploader::Base
|
4
|
-
|
5
2
|
# Include RMagick or MiniMagick support:
|
6
3
|
include CarrierWave::RMagick
|
7
4
|
# include CarrierWave::MiniMagick
|
@@ -28,7 +25,6 @@ class PhotoUploader < CarrierWave::Uploader::Base
|
|
28
25
|
ActionController::Base.helpers.asset_path "missing/#{model.class.to_s.tableize}/#{version_name}.png"
|
29
26
|
end
|
30
27
|
|
31
|
-
|
32
28
|
# Process files as they are uploaded:
|
33
29
|
# process :scale => [200, 300]
|
34
30
|
#
|
@@ -23,20 +23,12 @@ class Admin::<%= model_name.demodulize.pluralize -%>Controller < Admin::BaseCont
|
|
23
23
|
|
24
24
|
def create
|
25
25
|
@<%= resource_name %> = <%= model_name.demodulize -%>.new(<%= resource_name %>_params)
|
26
|
-
|
27
|
-
redirect_to params[:commit] == 'Применить' ? [:edit, :admin, @<%= resource_name %>] : [:admin, :<%= plural_resource_name %>], notice: "#{<%= model_name.demodulize -%>.model_name.human} добавлен."
|
28
|
-
else
|
29
|
-
render 'edit'
|
30
|
-
end
|
26
|
+
redirect_or_edit(@<%= resource_name %>, @<%= resource_name %>.save)
|
31
27
|
end
|
32
28
|
|
33
29
|
def update
|
34
30
|
@<%= resource_name %> = <%= model_name.demodulize -%>.find(params[:id])
|
35
|
-
|
36
|
-
redirect_to params[:commit] == 'Применить' ? [:edit, :admin, @<%= resource_name %>] : [:admin, :<%= plural_resource_name %>], notice: "#{<%= model_name.demodulize -%>.model_name.human} отредактирован."
|
37
|
-
else
|
38
|
-
render 'edit'
|
39
|
-
end
|
31
|
+
redirect_or_edit(@<%= resource_name %>, @<%= resource_name %>.update(<%= resource_name %>_params))
|
40
32
|
end
|
41
33
|
|
42
34
|
def destroy
|
@@ -46,8 +38,8 @@ class Admin::<%= model_name.demodulize.pluralize -%>Controller < Admin::BaseCont
|
|
46
38
|
end
|
47
39
|
|
48
40
|
private
|
49
|
-
def <%= resource_name %>_params
|
50
|
-
params.require(:<%= resource_name %>).permit(<%= column_names.select {|c| !(['id', 'updated_at', 'created_at'].include? c) }.map {|c| ":#{c}"}.join(', ') %>)
|
51
|
-
end
|
52
41
|
|
53
|
-
|
42
|
+
def <%= resource_name %>_params
|
43
|
+
params.require(:<%= resource_name %>).permit(<%= column_names.select {|c| !(['id', 'updated_at', 'created_at'].include? c) }.map { |c| ":#{c}" }.join(', ') %>)
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Redde::Photoable
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
belongs_to :imageable, polymorphic: true
|
6
|
+
default_scope { order(:position) }
|
7
|
+
before_save :set_token, unless: :persisted_link?
|
8
|
+
end
|
9
|
+
|
10
|
+
def set_token
|
11
|
+
token = SecureRandom.uuid unless token.present?
|
12
|
+
end
|
13
|
+
|
14
|
+
def persisted_link?
|
15
|
+
imageable_type.present? && imageable_id.present?
|
16
|
+
end
|
17
|
+
end
|
@@ -1,13 +1,27 @@
|
|
1
|
-
module WithPhoto
|
1
|
+
module Redde::WithPhoto
|
2
2
|
extend ActiveSupport::Concern
|
3
3
|
|
4
|
+
QUERY = 'imageable_id = :id AND imageable_type = :type OR token in (:tokens)'
|
5
|
+
|
4
6
|
included do
|
5
|
-
attr_accessor :
|
7
|
+
attr_accessor :photo_tokens
|
6
8
|
has_many :photos, dependent: :destroy, as: :imageable
|
7
9
|
after_create :assign_photos
|
8
10
|
end
|
9
11
|
|
12
|
+
def all_photos
|
13
|
+
Photo.where(QUERY, id: self.id, type: self.class.name, tokens: tokens)
|
14
|
+
end
|
15
|
+
|
10
16
|
def assign_photos
|
11
|
-
Photo.where(token: tokens
|
17
|
+
Photo.where(token: tokens).update_all(imageable_attributes)
|
18
|
+
end
|
19
|
+
|
20
|
+
def imageable_attributes
|
21
|
+
{ imageable_id: self.id, imageable_type: self.class.name, token: nil }
|
22
|
+
end
|
23
|
+
|
24
|
+
def tokens
|
25
|
+
photo_tokens || []
|
12
26
|
end
|
13
27
|
end
|
data/lib/redde/version.rb
CHANGED
data/lib/redde.rb
CHANGED
data/redde.gemspec
CHANGED
@@ -3,27 +3,27 @@
|
|
3
3
|
require File.expand_path('../lib/redde/version', __FILE__)
|
4
4
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
|
-
gem.authors = [
|
7
|
-
gem.email = [
|
6
|
+
gem.authors = ['Oleg Bovykin', 'Konstantin Gorozhankin']
|
7
|
+
gem.email = ['oleg.bovykin@gmail.com', 'konstantin.gorozhankin@gmail.com', 'info@redde.ru']
|
8
8
|
gem.description = %q{Admin scaffold generator for redde projects}
|
9
9
|
gem.summary = %q{Admin scaffold generator for redde projects}
|
10
|
-
gem.homepage =
|
10
|
+
gem.homepage = 'http://github.com/redde/redde'
|
11
11
|
|
12
12
|
gem.files = `git ls-files`.split($\)
|
13
13
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
14
14
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
15
|
-
gem.name =
|
16
|
-
gem.require_paths = [
|
15
|
+
gem.name = 'redde'
|
16
|
+
gem.require_paths = ['lib']
|
17
17
|
gem.version = Redde::VERSION
|
18
|
-
gem.license =
|
18
|
+
gem.license = 'MIT'
|
19
19
|
|
20
|
-
gem.add_runtime_dependency
|
21
|
-
gem.add_runtime_dependency
|
20
|
+
gem.add_runtime_dependency 'jquery-rails'
|
21
|
+
gem.add_runtime_dependency 'jquery-ui-rails'
|
22
22
|
|
23
23
|
gem.add_development_dependency 'rails', '>= 3.1'
|
24
24
|
gem.add_development_dependency 'rspec-rails', '>= 2.7'
|
25
25
|
gem.add_development_dependency 'factory_girl_rails', '>= 2.7'
|
26
26
|
gem.add_development_dependency 'guard-rspec'
|
27
|
-
gem.add_development_dependency
|
27
|
+
gem.add_development_dependency 'sqlite3'
|
28
28
|
gem.add_development_dependency 'generator_spec'
|
29
29
|
end
|
@@ -0,0 +1,5 @@
|
|
1
|
+
%li{ class: 'handle', id: "photo_#{photo.id}" }
|
2
|
+
= link_to photo.src.url do
|
3
|
+
= image_tag photo.src.admin
|
4
|
+
%em= photo.src.to_s.gsub(/.*\/(.*)\z/, '\1')
|
5
|
+
= link_to 'удалить', [:admin, photo.imageable, photo], method: :delete, data: { confirm: 'Точно удалить?'}, remote: true, title: 'Удалить', class: 'del'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
- unless parent.new_record?
|
2
|
+
= content_for(:page_sidebar) do
|
3
|
+
%h5
|
4
|
+
Фотографии
|
5
|
+
- if editable ||= false
|
6
|
+
= link_to 'ред.', [:admin, parent]
|
7
|
+
.product-photos
|
8
|
+
%ul.photos#photo-list
|
9
|
+
= render parent.photos
|
10
|
+
#preview
|
11
|
+
#drag-n-drop{ style: 'display: none; margin-top: 5px;' }
|
12
|
+
#drop-zone.b-dropzone{ style: 'height: 100px;', data: { 'upload-url' => url_for([:admin, parent, :photos]) } }
|
13
|
+
.b-dropzone__bg
|
14
|
+
.b-dropzone__txt Перетащите файлы сюда
|
15
|
+
#buttons-panel{ style: 'margin-bottom: 10px;' }
|
16
|
+
.b-button.js-fileapi-wrapper
|
17
|
+
.b-button__text Загрузить файлы
|
18
|
+
%input.b-button__input.js-fileapi{ name: 'files', type: 'file', multiple: true, data: { "upload-url" => url_for([:admin, parent, :photos]) } }
|
19
|
+
= photo_sortable url_for([:sort, :admin, parent, :photos])
|
@@ -0,0 +1 @@
|
|
1
|
+
$('ul.photos').append('<%= escape_javascript(render "admin/photos/photo", { photo: @photo, parent: @parent }) %>');
|
@@ -0,0 +1 @@
|
|
1
|
+
$("li#photo_<%= @photo.id%>").remove();
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreatePhotos < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :photos do |t|
|
4
|
+
t.integer :imageable_id
|
5
|
+
t.string :imageable_type
|
6
|
+
t.integer :position
|
7
|
+
t.string :src
|
8
|
+
t.string :token
|
9
|
+
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
add_index :photos, :imageable_id
|
13
|
+
add_index :photos, :imageable_type
|
14
|
+
add_index :photos, :token
|
15
|
+
end
|
16
|
+
end
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended that you check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(version:
|
14
|
+
ActiveRecord::Schema.define(version: 20140607122532) do
|
15
15
|
|
16
16
|
create_table "article_categories", force: true do |t|
|
17
17
|
t.string "title"
|
@@ -26,4 +26,73 @@ ActiveRecord::Schema.define(version: 20140128152208) do
|
|
26
26
|
t.datetime "created_at"
|
27
27
|
t.datetime "updated_at"
|
28
28
|
end
|
29
|
+
|
30
|
+
create_table "photos", force: true do |t|
|
31
|
+
t.integer "imageable_id"
|
32
|
+
t.string "imageable_type"
|
33
|
+
t.integer "position"
|
34
|
+
t.string "src"
|
35
|
+
t.string "token"
|
36
|
+
t.datetime "created_at"
|
37
|
+
t.datetime "updated_at"
|
38
|
+
end
|
39
|
+
|
40
|
+
add_index "photos", ["imageable_id"], name: "index_photos_on_imageable_id"
|
41
|
+
add_index "photos", ["imageable_type"], name: "index_photos_on_imageable_type"
|
42
|
+
add_index "photos", ["token"], name: "index_photos_on_token"
|
43
|
+
|
44
|
+
create_table "redditor_images", force: true do |t|
|
45
|
+
t.integer "imageable_id"
|
46
|
+
t.string "imageable_type"
|
47
|
+
t.integer "position"
|
48
|
+
t.string "src"
|
49
|
+
t.string "description"
|
50
|
+
t.datetime "created_at", null: false
|
51
|
+
t.datetime "updated_at", null: false
|
52
|
+
end
|
53
|
+
|
54
|
+
add_index "redditor_images", ["imageable_id"], name: "index_redditor_images_on_imageable_id"
|
55
|
+
add_index "redditor_images", ["imageable_type"], name: "index_redditor_images_on_imageable_type"
|
56
|
+
|
57
|
+
create_table "redditor_pages", force: true do |t|
|
58
|
+
t.integer "pageable_id"
|
59
|
+
t.string "pageable_type"
|
60
|
+
t.datetime "created_at", null: false
|
61
|
+
t.datetime "updated_at", null: false
|
62
|
+
end
|
63
|
+
|
64
|
+
add_index "redditor_pages", ["pageable_id"], name: "index_redditor_pages_on_pageable_id"
|
65
|
+
add_index "redditor_pages", ["pageable_type"], name: "index_redditor_pages_on_pageable_type"
|
66
|
+
|
67
|
+
create_table "redditor_slider_blocks", force: true do |t|
|
68
|
+
t.integer "page_id"
|
69
|
+
t.integer "position"
|
70
|
+
t.datetime "created_at", null: false
|
71
|
+
t.datetime "updated_at", null: false
|
72
|
+
end
|
73
|
+
|
74
|
+
add_index "redditor_slider_blocks", ["page_id"], name: "index_redditor_slider_blocks_on_page_id"
|
75
|
+
|
76
|
+
create_table "redditor_text_blocks", force: true do |t|
|
77
|
+
t.integer "page_id"
|
78
|
+
t.text "body"
|
79
|
+
t.integer "position"
|
80
|
+
t.datetime "created_at", null: false
|
81
|
+
t.datetime "updated_at", null: false
|
82
|
+
end
|
83
|
+
|
84
|
+
add_index "redditor_text_blocks", ["page_id"], name: "index_redditor_text_blocks_on_page_id"
|
85
|
+
|
86
|
+
create_table "redditor_video_blocks", force: true do |t|
|
87
|
+
t.integer "page_id"
|
88
|
+
t.integer "position"
|
89
|
+
t.integer "width"
|
90
|
+
t.integer "height"
|
91
|
+
t.string "youtube"
|
92
|
+
t.datetime "created_at", null: false
|
93
|
+
t.datetime "updated_at", null: false
|
94
|
+
end
|
95
|
+
|
96
|
+
add_index "redditor_video_blocks", ["page_id"], name: "index_redditor_video_blocks_on_page_id"
|
97
|
+
|
29
98
|
end
|
@@ -2,11 +2,12 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Redde::Generators::LayoutGenerator do
|
4
4
|
include GeneratorSpec::TestCase
|
5
|
-
destination File.expand_path(
|
5
|
+
destination File.expand_path('../../../tmp', __FILE__)
|
6
6
|
arguments %w(something)
|
7
7
|
|
8
8
|
before(:all) do
|
9
9
|
prepare_destination
|
10
|
+
`mkdir tmp/config; touch tmp/config/routes.rb; echo "Rails.application.routes.draw do\nend" > tmp/config/routes.rb`
|
10
11
|
run_generator
|
11
12
|
end
|
12
13
|
|
@@ -14,28 +15,25 @@ describe Redde::Generators::LayoutGenerator do
|
|
14
15
|
FileUtils.rm_rf 'tmp'
|
15
16
|
end
|
16
17
|
|
17
|
-
describe
|
18
|
-
|
19
|
-
it "Generates admin and login layouts with js and css" do
|
18
|
+
describe 'layout' do
|
19
|
+
it 'Generates admin and login layouts with js and css' do
|
20
20
|
# check layouts
|
21
|
-
assert_file
|
22
|
-
assert_file
|
21
|
+
assert_file 'app/views/layouts/admin.html.haml'
|
22
|
+
assert_file 'app/views/layouts/login.html.haml'
|
23
23
|
|
24
24
|
# check shared
|
25
|
-
assert_file
|
26
|
-
assert_file
|
27
|
-
assert_file
|
25
|
+
assert_file 'app/views/admin/base/_launchbar.html.haml'
|
26
|
+
assert_file 'app/views/admin/base/_sidebar.html.haml'
|
27
|
+
assert_file 'app/views/admin/base/_header.html.haml'
|
28
28
|
|
29
29
|
# check js and css
|
30
|
-
assert_file
|
31
|
-
assert_file
|
30
|
+
assert_file 'app/assets/javascripts/admin.js'
|
31
|
+
assert_file 'app/assets/stylesheets/admin/index.scss'
|
32
32
|
|
33
|
-
#check images
|
34
|
-
assert_directory
|
35
|
-
assert_directory
|
36
|
-
assert_directory
|
33
|
+
# check images
|
34
|
+
assert_directory 'app/assets/images/admin'
|
35
|
+
assert_directory 'app/assets/javascripts/admin'
|
36
|
+
assert_directory 'app/assets/stylesheets/admin'
|
37
37
|
end
|
38
|
-
|
39
38
|
end
|
40
|
-
|
41
|
-
end
|
39
|
+
end
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Redde::Generators::PhotoGenerator do
|
4
4
|
include GeneratorSpec::TestCase
|
5
|
-
destination File.expand_path(
|
5
|
+
destination File.expand_path('../../../tmp', __FILE__)
|
6
6
|
|
7
7
|
before(:all) do
|
8
8
|
prepare_destination
|
@@ -13,21 +13,20 @@ describe Redde::Generators::PhotoGenerator do
|
|
13
13
|
FileUtils.rm_rf 'tmp'
|
14
14
|
end
|
15
15
|
|
16
|
-
it
|
17
|
-
assert_file
|
16
|
+
it 'Generates controller' do
|
17
|
+
assert_file 'app/controllers/admin/photos_controller.rb'
|
18
18
|
end
|
19
19
|
|
20
|
-
it
|
21
|
-
assert_directory
|
20
|
+
it 'Generates views' do
|
21
|
+
assert_directory 'app/views/admin/photos'
|
22
22
|
end
|
23
23
|
|
24
|
-
it
|
25
|
-
assert_file
|
24
|
+
it 'Generates model' do
|
25
|
+
assert_file 'app/models/photo.rb'
|
26
26
|
end
|
27
27
|
|
28
|
-
it
|
29
|
-
files = Dir[
|
30
|
-
expect(files.map(&:to_s).join(
|
28
|
+
it 'Generates migration' do
|
29
|
+
files = Dir['tmp/db/migrate/*.rb']
|
30
|
+
expect(files.map(&:to_s).join(' ').index('create_photos')).to eq 30
|
31
31
|
end
|
32
|
-
|
33
|
-
end
|
32
|
+
end
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Redde::Generators::ScaffoldGenerator do
|
4
4
|
include GeneratorSpec::TestCase
|
5
|
-
destination File.expand_path(
|
5
|
+
destination File.expand_path('../../../tmp', __FILE__)
|
6
6
|
arguments ['Articles']
|
7
7
|
|
8
8
|
before(:all) do
|
@@ -14,46 +14,45 @@ describe Redde::Generators::ScaffoldGenerator do
|
|
14
14
|
FileUtils.rm_rf 'tmp'
|
15
15
|
end
|
16
16
|
|
17
|
-
let(:args) { [
|
17
|
+
let(:args) { ['ArticleCategory'] }
|
18
18
|
let(:generator) { Redde::Generators::ScaffoldGenerator.new(args) }
|
19
19
|
|
20
|
-
context
|
21
|
-
it
|
22
|
-
expect(generator.send(:controller_routing_path)).to eq
|
20
|
+
context 'METHODS' do
|
21
|
+
it 'gets controller_routing_path' do
|
22
|
+
expect(generator.send(:controller_routing_path)).to eq 'article_category'
|
23
23
|
end
|
24
24
|
|
25
|
-
it
|
26
|
-
|
25
|
+
it 'gets singular_controller_routing_path' do
|
26
|
+
res = generator.send(:singular_controller_routing_path)
|
27
|
+
expect(res).to eq 'article_category'
|
27
28
|
end
|
28
29
|
|
29
|
-
it
|
30
|
-
expect(generator.send(:model_name)).to eq
|
30
|
+
it 'gets model_name' do
|
31
|
+
expect(generator.send(:model_name)).to eq '::ArticleCategory'
|
31
32
|
end
|
32
33
|
|
33
|
-
it
|
34
|
-
expect(generator.send(:plural_model_name)).to eq
|
34
|
+
it 'gets plural_model_name' do
|
35
|
+
expect(generator.send(:plural_model_name)).to eq '::ArticleCategories'
|
35
36
|
end
|
36
37
|
|
37
|
-
it
|
38
|
-
expect(generator.send(:resource_name)).to eq
|
38
|
+
it 'gets resource_name' do
|
39
|
+
expect(generator.send(:resource_name)).to eq 'article_category'
|
39
40
|
end
|
40
41
|
|
41
|
-
it
|
42
|
-
expect(generator.send(:plural_resource_name)).to eq
|
42
|
+
it 'gets plural_resource_name' do
|
43
|
+
expect(generator.send(:plural_resource_name)).to eq 'article_categories'
|
43
44
|
end
|
44
45
|
|
45
|
-
it
|
46
|
-
expect(generator.send(:index_header)).to eq
|
46
|
+
it 'gets index header' do
|
47
|
+
expect(generator.send(:index_header)).to eq 'Article categories'
|
47
48
|
end
|
48
|
-
end # end context
|
49
|
+
end # end context 'METHODS'
|
49
50
|
|
50
|
-
context
|
51
|
-
|
52
|
-
|
53
|
-
assert_file
|
54
|
-
assert_file "app/views/admin/articles/edit.html.haml"
|
51
|
+
context 'INTEGRATION' do
|
52
|
+
it 'Generates admin views' do
|
53
|
+
assert_file 'app/views/admin/articles/index.html.haml'
|
54
|
+
assert_file 'app/views/admin/articles/edit.html.haml'
|
55
55
|
end
|
56
56
|
|
57
|
-
end # end describe
|
58
|
-
|
59
|
-
end
|
57
|
+
end # end describe 'VIEWS'
|
58
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Redde::WithPhoto do
|
4
|
+
let(:photo1) { Photo.create(src: '/uploads/1.txt', token: rand(1000)) }
|
5
|
+
let(:photo2) { Photo.create(src: '/uploads/2.txt', token: rand(1000)) }
|
6
|
+
let(:tokens) { [photo1.token, photo2.token] }
|
7
|
+
let(:only_token) { { imageable_type: nil, imageable_id: nil, token: 123 } }
|
8
|
+
let(:article) { Article.new(title: 'Test Title', photo_tokens: tokens) }
|
9
|
+
|
10
|
+
it 'assigns photos to article' do
|
11
|
+
Photo.delete_all
|
12
|
+
article.save
|
13
|
+
expect(article.photos.count).to eq 2
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'it gets all photos for article' do
|
17
|
+
Photo.delete_all
|
18
|
+
article.save
|
19
|
+
article.reload
|
20
|
+
article.photos.first.update(only_token)
|
21
|
+
article.photo_tokens = [123]
|
22
|
+
expect(article.all_photos.count).to eq 2
|
23
|
+
expect(article.photos.count).to eq 1
|
24
|
+
end
|
25
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,29 +1,22 @@
|
|
1
|
-
ENV[
|
2
|
-
require File.expand_path(
|
3
|
-
|
1
|
+
ENV['RAILS_ENV'] ||= 'test'
|
2
|
+
require File.expand_path('../dummy/config/environment', __FILE__)
|
4
3
|
require 'bundler/setup'
|
5
4
|
require 'rails/all'
|
6
5
|
require 'active_record'
|
7
|
-
|
8
6
|
require 'rspec/rails'
|
9
7
|
require 'rspec/autorun'
|
10
|
-
|
11
8
|
require 'factory_girl'
|
12
|
-
|
13
|
-
|
14
9
|
require 'generator_spec/test_case'
|
15
10
|
require 'redde'
|
16
|
-
Dir[Pathname.new(File.expand_path('../', __FILE__)).join('support/**/*.rb')].each {|f| require f}
|
17
11
|
|
18
12
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
19
13
|
# in spec/support/ and its subdirectories.
|
20
|
-
Dir[Rails.root.join(
|
14
|
+
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
|
21
15
|
|
22
16
|
# Checks for pending migrations before tests are run.
|
23
17
|
# If you are not using ActiveRecord, you can remove this line.
|
24
18
|
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
|
25
19
|
|
26
|
-
|
27
20
|
RSpec.configure do |config|
|
28
21
|
# ## Mock Framework
|
29
22
|
#
|
@@ -34,9 +27,9 @@ RSpec.configure do |config|
|
|
34
27
|
# config.mock_with :rr
|
35
28
|
|
36
29
|
# config.after(:all) do
|
37
|
-
# if Rails.env.test?
|
38
|
-
# FileUtils.rm_rf(Dir[
|
39
|
-
# end
|
30
|
+
# if Rails.env.test?
|
31
|
+
# FileUtils.rm_rf(Dir['#{Rails.root}/public/uploads'])
|
32
|
+
# end
|
40
33
|
# end
|
41
34
|
|
42
35
|
config.include FactoryGirl::Syntax::Methods
|
@@ -55,5 +48,5 @@ RSpec.configure do |config|
|
|
55
48
|
# order dependency and want to debug it, you can fix the order by providing
|
56
49
|
# the seed, which is printed after each run.
|
57
50
|
# --seed 1234
|
58
|
-
config.order =
|
51
|
+
config.order = 'random'
|
59
52
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redde
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oleg Bovykin
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-06-
|
12
|
+
date: 2014-06-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jquery-rails
|
@@ -228,6 +228,8 @@ files:
|
|
228
228
|
- lib/generators/redde/layout/templates/base/_validate.haml
|
229
229
|
- lib/generators/redde/layout/templates/base/welcome.haml
|
230
230
|
- lib/generators/redde/layout/templates/controllers/base_controller.rb
|
231
|
+
- lib/generators/redde/layout/templates/controllers/managers/registrations_controller.rb
|
232
|
+
- lib/generators/redde/layout/templates/controllers/managers_controller.rb
|
231
233
|
- lib/generators/redde/layout/templates/helpers/admin_helper.rb
|
232
234
|
- lib/generators/redde/layout/templates/layouts/admin.html.haml
|
233
235
|
- lib/generators/redde/layout/templates/layouts/login.html.haml
|
@@ -246,6 +248,7 @@ files:
|
|
246
248
|
- lib/generators/redde/scaffold/templates/index.html.haml
|
247
249
|
- lib/redde.rb
|
248
250
|
- lib/redde/concerns/layout.rb
|
251
|
+
- lib/redde/concerns/photoable.rb
|
249
252
|
- lib/redde/concerns/sluggable.rb
|
250
253
|
- lib/redde/concerns/with_photo.rb
|
251
254
|
- lib/redde/url_generator.rb
|
@@ -262,6 +265,11 @@ files:
|
|
262
265
|
- spec/dummy/app/models/.keep
|
263
266
|
- spec/dummy/app/models/article.rb
|
264
267
|
- spec/dummy/app/models/article_category.rb
|
268
|
+
- spec/dummy/app/models/photo.rb
|
269
|
+
- spec/dummy/app/views/admin/photos/_photo.haml
|
270
|
+
- spec/dummy/app/views/admin/photos/_photos.haml
|
271
|
+
- spec/dummy/app/views/admin/photos/create.js.erb
|
272
|
+
- spec/dummy/app/views/admin/photos/destroy.js.erb
|
265
273
|
- spec/dummy/app/views/articles/show.html.haml
|
266
274
|
- spec/dummy/app/views/layouts/application.html.erb
|
267
275
|
- spec/dummy/bin/bundle
|
@@ -284,11 +292,10 @@ files:
|
|
284
292
|
- spec/dummy/config/initializers/wrap_parameters.rb
|
285
293
|
- spec/dummy/config/locales/en.yml
|
286
294
|
- spec/dummy/config/routes.rb
|
287
|
-
- spec/dummy/db/development.sqlite3
|
288
295
|
- spec/dummy/db/migrate/20130908123351_create_articles.rb
|
289
296
|
- spec/dummy/db/migrate/20140128152208_create_article_categories.rb
|
297
|
+
- spec/dummy/db/migrate/20140607122532_create_photos.rb
|
290
298
|
- spec/dummy/db/schema.rb
|
291
|
-
- spec/dummy/db/test.sqlite3
|
292
299
|
- spec/dummy/lib/assets/.keep
|
293
300
|
- spec/dummy/log/.keep
|
294
301
|
- spec/dummy/public/404.html
|
@@ -300,6 +307,7 @@ files:
|
|
300
307
|
- spec/generators/scaffold_generator_spec.rb
|
301
308
|
- spec/models/sluggable_spec.rb
|
302
309
|
- spec/models/url_generator_spec.rb
|
310
|
+
- spec/models/with_photo_spec.rb
|
303
311
|
- spec/spec_helper.rb
|
304
312
|
homepage: http://github.com/redde/redde
|
305
313
|
licenses:
|
@@ -337,6 +345,11 @@ test_files:
|
|
337
345
|
- spec/dummy/app/models/.keep
|
338
346
|
- spec/dummy/app/models/article.rb
|
339
347
|
- spec/dummy/app/models/article_category.rb
|
348
|
+
- spec/dummy/app/models/photo.rb
|
349
|
+
- spec/dummy/app/views/admin/photos/_photo.haml
|
350
|
+
- spec/dummy/app/views/admin/photos/_photos.haml
|
351
|
+
- spec/dummy/app/views/admin/photos/create.js.erb
|
352
|
+
- spec/dummy/app/views/admin/photos/destroy.js.erb
|
340
353
|
- spec/dummy/app/views/articles/show.html.haml
|
341
354
|
- spec/dummy/app/views/layouts/application.html.erb
|
342
355
|
- spec/dummy/bin/bundle
|
@@ -359,11 +372,10 @@ test_files:
|
|
359
372
|
- spec/dummy/config/initializers/wrap_parameters.rb
|
360
373
|
- spec/dummy/config/locales/en.yml
|
361
374
|
- spec/dummy/config/routes.rb
|
362
|
-
- spec/dummy/db/development.sqlite3
|
363
375
|
- spec/dummy/db/migrate/20130908123351_create_articles.rb
|
364
376
|
- spec/dummy/db/migrate/20140128152208_create_article_categories.rb
|
377
|
+
- spec/dummy/db/migrate/20140607122532_create_photos.rb
|
365
378
|
- spec/dummy/db/schema.rb
|
366
|
-
- spec/dummy/db/test.sqlite3
|
367
379
|
- spec/dummy/lib/assets/.keep
|
368
380
|
- spec/dummy/log/.keep
|
369
381
|
- spec/dummy/public/404.html
|
@@ -375,4 +387,5 @@ test_files:
|
|
375
387
|
- spec/generators/scaffold_generator_spec.rb
|
376
388
|
- spec/models/sluggable_spec.rb
|
377
389
|
- spec/models/url_generator_spec.rb
|
390
|
+
- spec/models/with_photo_spec.rb
|
378
391
|
- spec/spec_helper.rb
|
Binary file
|
data/spec/dummy/db/test.sqlite3
DELETED
Binary file
|