acts_as_assets 0.2.6 → 0.3.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.
- data/app/controllers/acts_as_assets/assets_controller.rb +15 -16
- data/app/helpers/acts_as_assets/assets_helper.rb +29 -16
- data/app/views/acts_as_assets/assets/_asset.html.erb +2 -1
- data/lib/acts_as_assets/base.rb +17 -17
- data/lib/acts_as_assets/form_helper.rb +7 -3
- data/lib/acts_as_assets/version.rb +1 -1
- data/spec/controllers/assets_controller_spec.rb +9 -13
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +2 -0
- data/spec/dummy/log/test.log +12255 -0
- data/spec/routing/assets_routing_spec.rb +7 -7
- data/spec/spec_helper.rb +6 -7
- data/spec/support/book.rb +2 -2
- data/spec/support/chapter.rb +1 -1
- data/spec/support/tipo_pannello.rb +1 -1
- metadata +8 -4
@@ -3,27 +3,27 @@ require "spec_helper"
|
|
3
3
|
describe Books::AssetsController do
|
4
4
|
|
5
5
|
it {should route(:get,'books/1/assets/TestDoc').to(
|
6
|
-
:controller => "books/assets", :action => :index, :
|
6
|
+
:controller => "books/assets", :action => :index, :fk_name => 1, :type => "TestDoc")}
|
7
7
|
|
8
8
|
it {should route(:get,'books/1/assets/my/asset/type').to(
|
9
|
-
:controller => "books/assets", :action => :index, :
|
9
|
+
:controller => "books/assets", :action => :index, :fk_name => 1, :type => "my/asset/type")}
|
10
10
|
|
11
11
|
it {should route(:post,'books/1/assets/TestDoc.js').to(
|
12
|
-
:controller => "books/assets", :action => :create, :
|
12
|
+
:controller => "books/assets", :action => :create, :fk_name => 1, :type => "TestDoc", :format => 'js')}
|
13
13
|
|
14
14
|
it {should route(:delete,'books/1/assets/20.js').to(
|
15
|
-
:controller => "books/assets", :action => :destroy, :
|
15
|
+
:controller => "books/assets", :action => :destroy, :fk_name => 1, :format => 'js', :asset_id => 20)}
|
16
16
|
|
17
17
|
it {should route(:get,'books/1/assets/get/20/thumb/filename.gif').to(
|
18
|
-
:controller => "books/assets", :action => :get, :
|
18
|
+
:controller => "books/assets", :action => :get, :fk_name => 1, :style => "thumb", :asset_id => 20, :filename => "filename", :extension => "gif" )}
|
19
19
|
|
20
20
|
it {should route(:get,'books/1/assets/get/20/filename.gif').to(
|
21
|
-
:controller => "books/assets", :action => :get, :
|
21
|
+
:controller => "books/assets", :action => :get, :fk_name => 1, :asset_id => 20, :filename => "filename", :extension => "gif")}
|
22
22
|
|
23
23
|
end
|
24
24
|
|
25
25
|
describe TipiPannello::AssetsController do
|
26
26
|
it {should route(:delete,'tipi_pannello/il_mio_tipo/assets/20.js').to(
|
27
|
-
:controller => "tipi_pannello/assets", :action => :destroy, :
|
27
|
+
:controller => "tipi_pannello/assets", :action => :destroy, :fk_name=> 'il_mio_tipo', :format => 'js', :asset_id => 20)}
|
28
28
|
|
29
29
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -28,7 +28,7 @@ RSpec.configure do |config|
|
|
28
28
|
t.string :title
|
29
29
|
end
|
30
30
|
ActiveRecord::Base.connection.create_table(:books_assets, :force => true) do |t|
|
31
|
-
t.
|
31
|
+
t.attachment :asset
|
32
32
|
t.string :type
|
33
33
|
t.integer :counter, :default => 0, :null => false
|
34
34
|
t.integer :book_id
|
@@ -38,7 +38,7 @@ RSpec.configure do |config|
|
|
38
38
|
t.string :name, :null => false
|
39
39
|
end
|
40
40
|
ActiveRecord::Base.connection.create_table(:chapters_assets, :force => true) do |t|
|
41
|
-
t.
|
41
|
+
t.attachment :asset
|
42
42
|
t.string :type
|
43
43
|
t.integer :counter, :default => 0, :null => false
|
44
44
|
t.string :chapter_name
|
@@ -48,26 +48,26 @@ RSpec.configure do |config|
|
|
48
48
|
t.string :name, :null => false
|
49
49
|
end
|
50
50
|
ActiveRecord::Base.connection.create_table(:rt_tipi_pannello_assets, :force => true) do |t|
|
51
|
-
t.
|
51
|
+
t.attachment :asset
|
52
52
|
t.string :type
|
53
53
|
t.integer :counter, :default => 0, :null => false
|
54
54
|
t.boolean :displayable, :default => false, :null => false
|
55
55
|
t.string :tipo_pannello_name
|
56
56
|
end
|
57
57
|
Rails.application.routes.draw do
|
58
|
-
scope "books/:
|
58
|
+
scope "books/:fk_name/assets/" do
|
59
59
|
get 'get/:asset_id/(:style)/:filename.:extension' => 'books/assets#get', :as => 'book_get_asset'
|
60
60
|
get '*type' => 'books/assets#index', :as => 'book_assets'
|
61
61
|
post '*type' => 'books/assets#create', :as => 'book_create_asset'
|
62
62
|
delete ':asset_id' => 'books/assets#destroy', :as => 'book_destroy_asset'
|
63
63
|
end
|
64
|
-
scope "chapters/:
|
64
|
+
scope "chapters/:fk_name/assets/", :chapter_name => /.*/ do
|
65
65
|
get 'get/:asset_id/(:style)/:filename.:extension' => 'chapters/assets#get', :as => 'chapter_get_asset'
|
66
66
|
get '*type' => 'chapters/assets#index', :as => 'chapter_assets'
|
67
67
|
post '*type' => 'chapters/assets#create', :as => 'chapter_create_asset'
|
68
68
|
delete ':asset_id' => 'chapters/assets#destroy', :as => 'chapter_destroy_asset'
|
69
69
|
end
|
70
|
-
scope "tipi_pannello/:
|
70
|
+
scope "tipi_pannello/:fk_name/assets/" do
|
71
71
|
get 'get/:asset_id/(:style)/:filename.:extension' => 'tipi_pannello/assets#get', :as => 'tipo_pannello_get_asset'
|
72
72
|
get '*type' => 'tipi_pannello/assets#index', :as => 'tipo_pannello_assets'
|
73
73
|
post '*type' => 'tipi_pannello/assets#create', :as => 'tipo_pannello_create_asset'
|
@@ -80,7 +80,6 @@ RSpec.configure do |config|
|
|
80
80
|
require 'fileutils'
|
81
81
|
Dir[File.expand_path("../public/*", __FILE__)].each {|file| FileUtils.rm_rf file }
|
82
82
|
Dir[File.expand_path("../temp/*", __FILE__)].each {|file| FileUtils.rm_rf file }
|
83
|
-
puts "Cleaned up files"
|
84
83
|
end
|
85
84
|
|
86
85
|
config.before(:each) do
|
data/spec/support/book.rb
CHANGED
@@ -5,7 +5,7 @@ end
|
|
5
5
|
module Books
|
6
6
|
class Asset < ActiveRecord::Base
|
7
7
|
self.table_name = "books_assets"
|
8
|
-
acts_as_assets
|
8
|
+
acts_as_assets base_model: :book
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
@@ -27,7 +27,7 @@ end
|
|
27
27
|
module Books
|
28
28
|
class Image < ActiveRecord::Base
|
29
29
|
self.table_name = "books_assets"
|
30
|
-
acts_as_assets :styles => {:thumb => "64x64", :medium => "128x128", :original => "800x600<"}
|
30
|
+
acts_as_assets base_model: :book,:styles => {:thumb => "64x64", :medium => "128x128", :original => "800x600<"}
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
data/spec/support/chapter.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-06-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -194,8 +194,10 @@ files:
|
|
194
194
|
- spec/dummy/config/locales/en.yml
|
195
195
|
- spec/dummy/config/routes.rb
|
196
196
|
- spec/dummy/config.ru
|
197
|
+
- spec/dummy/db/development.sqlite3
|
197
198
|
- spec/dummy/db/schema.rb
|
198
199
|
- spec/dummy/db/test.sqlite3
|
200
|
+
- spec/dummy/log/development.log
|
199
201
|
- spec/dummy/log/test.log
|
200
202
|
- spec/dummy/public/404.html
|
201
203
|
- spec/dummy/public/422.html
|
@@ -229,7 +231,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
229
231
|
version: '0'
|
230
232
|
segments:
|
231
233
|
- 0
|
232
|
-
hash:
|
234
|
+
hash: 4562825233494503054
|
233
235
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
234
236
|
none: false
|
235
237
|
requirements:
|
@@ -238,7 +240,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
238
240
|
version: '0'
|
239
241
|
segments:
|
240
242
|
- 0
|
241
|
-
hash:
|
243
|
+
hash: 4562825233494503054
|
242
244
|
requirements: []
|
243
245
|
rubyforge_project:
|
244
246
|
rubygems_version: 1.8.21
|
@@ -269,8 +271,10 @@ test_files:
|
|
269
271
|
- spec/dummy/config/locales/en.yml
|
270
272
|
- spec/dummy/config/routes.rb
|
271
273
|
- spec/dummy/config.ru
|
274
|
+
- spec/dummy/db/development.sqlite3
|
272
275
|
- spec/dummy/db/schema.rb
|
273
276
|
- spec/dummy/db/test.sqlite3
|
277
|
+
- spec/dummy/log/development.log
|
274
278
|
- spec/dummy/log/test.log
|
275
279
|
- spec/dummy/public/404.html
|
276
280
|
- spec/dummy/public/422.html
|