acts_as_assets 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +0 -0
- data/Rakefile +28 -0
- data/app/controllers/acts_as_assets/assets_controller.rb +74 -0
- data/app/views/acts_as_assets/assets/destroy.js.erb +1 -0
- data/app/views/acts_as_assets/assets/index.html.erb +12 -0
- data/config/routes.rb +2 -0
- data/lib/acts_as_assets/base.rb +62 -0
- data/lib/acts_as_assets/engine.rb +4 -0
- data/lib/acts_as_assets/interpolations.rb +18 -0
- data/lib/acts_as_assets/version.rb +3 -0
- data/lib/acts_as_assets.rb +3 -0
- data/lib/tasks/acts_as_assets_tasks.rake +4 -0
- data/spec/acts_as_assets_spec.rb +126 -0
- data/spec/controllers/assets_controller_spec.rb +139 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config/application.rb +62 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +58 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +3 -0
- data/spec/dummy/log/test.log +8247 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/resources/jpg_test.jpg +0 -0
- data/spec/routing/assets_routing_spec.rb +17 -0
- data/spec/spec_helper.rb +59 -0
- data/spec/support/book.rb +3 -0
- data/spec/support/books_asset.rb +6 -0
- data/spec/support/books_assets_controller.rb +3 -0
- data/spec/support/books_assets_test_doc.rb +6 -0
- metadata +211 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/404.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
23
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/422.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/500.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
23
|
+
</div>
|
24
|
+
</body>
|
25
|
+
</html>
|
File without changes
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
Binary file
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Books::AssetsController do
|
4
|
+
|
5
|
+
it {should route(:get,'books/1/assets/TestDoc').to(
|
6
|
+
:controller => "books/assets", :action => :index, :book_id => 1, :type => "TestDoc")}
|
7
|
+
|
8
|
+
it {should route(:get,'books/1/assets/my/asset/type').to(
|
9
|
+
:controller => "books/assets", :action => :index, :book_id => 1, :type => ["my","asset","type"])}
|
10
|
+
|
11
|
+
it {should route(:post,'books/1/assets/TestDoc.js').to(
|
12
|
+
:controller => "books/assets", :action => :create, :book_id => 1, :type => "TestDoc", :format => 'js')}
|
13
|
+
|
14
|
+
it {should route(:delete,'books/1/assets/20.js').to(
|
15
|
+
:controller => "books/assets", :action => :destroy, :book_id => 1, :format => 'js', :id => 20)}
|
16
|
+
|
17
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'rubygems'
|
3
|
+
|
4
|
+
ENV["RAILS_ENV"] ||= 'test'
|
5
|
+
|
6
|
+
require 'rails/all'
|
7
|
+
require 'acts_as_assets'
|
8
|
+
require 'rack/test/uploaded_file'
|
9
|
+
require 'paperclip'
|
10
|
+
require 'shoulda/matchers'
|
11
|
+
require 'paperclip/matchers'
|
12
|
+
|
13
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
14
|
+
ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
|
15
|
+
Dir[File.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb")].each {|f| require f }
|
16
|
+
|
17
|
+
require 'rspec/rails'
|
18
|
+
|
19
|
+
RSpec.configure do |config|
|
20
|
+
include Shoulda::Matchers::ActionController
|
21
|
+
include Paperclip::Shoulda::Matchers
|
22
|
+
|
23
|
+
config.mock_with :rspec
|
24
|
+
|
25
|
+
config.before :suite do
|
26
|
+
ActiveRecord::Base.connection.create_table(:books,:force => true) do |t|
|
27
|
+
t.string :title
|
28
|
+
end
|
29
|
+
ActiveRecord::Base.connection.create_table(:books_assets,:force => true) do |t|
|
30
|
+
t.has_attached_file :asset
|
31
|
+
t.string :type
|
32
|
+
t.integer :counter, :default => 0, :null => false
|
33
|
+
t.integer :book_id
|
34
|
+
end
|
35
|
+
Rails.application.routes.draw do
|
36
|
+
namespace :books do
|
37
|
+
scope ":book_id/assets" do
|
38
|
+
get '*type' => 'assets#index', :as => 'assets'
|
39
|
+
post ':type' => 'assets#create', :as => 'assets_create'
|
40
|
+
delete ':asset_id' => 'assets#destroy', :as => 'assets_destroy'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
config.before(:each) do
|
48
|
+
Books::Asset.delete_all
|
49
|
+
Book.delete_all
|
50
|
+
end
|
51
|
+
|
52
|
+
config.after(:suite) do
|
53
|
+
end
|
54
|
+
|
55
|
+
def jpg_test
|
56
|
+
Rack::Test::UploadedFile.new(File.expand_path('../resources/jpg_test.jpg',__FILE__), "image/jpeg")
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
metadata
ADDED
@@ -0,0 +1,211 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: acts_as_assets
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Andrea Campolonghi
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-02-13 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: &70134249062460 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.2.1
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70134249062460
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: paperclip
|
27
|
+
requirement: &70134249062040 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70134249062040
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: sqlite3
|
38
|
+
requirement: &70134249061580 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70134249061580
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rspec-rails
|
49
|
+
requirement: &70134249061160 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70134249061160
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: paperclip
|
60
|
+
requirement: &70134249060740 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70134249060740
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: shoulda-matchers
|
71
|
+
requirement: &70134249060320 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70134249060320
|
80
|
+
description: ''
|
81
|
+
email:
|
82
|
+
- acampolonghi@gmail.com
|
83
|
+
executables: []
|
84
|
+
extensions: []
|
85
|
+
extra_rdoc_files: []
|
86
|
+
files:
|
87
|
+
- app/controllers/acts_as_assets/assets_controller.rb
|
88
|
+
- app/views/acts_as_assets/assets/destroy.js.erb
|
89
|
+
- app/views/acts_as_assets/assets/index.html.erb
|
90
|
+
- config/routes.rb
|
91
|
+
- lib/acts_as_assets/base.rb
|
92
|
+
- lib/acts_as_assets/engine.rb
|
93
|
+
- lib/acts_as_assets/interpolations.rb
|
94
|
+
- lib/acts_as_assets/version.rb
|
95
|
+
- lib/acts_as_assets.rb
|
96
|
+
- lib/tasks/acts_as_assets_tasks.rake
|
97
|
+
- Rakefile
|
98
|
+
- README.md
|
99
|
+
- spec/acts_as_assets_spec.rb
|
100
|
+
- spec/controllers/assets_controller_spec.rb
|
101
|
+
- spec/dummy/app/assets/javascripts/application.js
|
102
|
+
- spec/dummy/app/assets/stylesheets/application.css
|
103
|
+
- spec/dummy/app/controllers/application_controller.rb
|
104
|
+
- spec/dummy/app/helpers/application_helper.rb
|
105
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
106
|
+
- spec/dummy/config/application.rb
|
107
|
+
- spec/dummy/config/boot.rb
|
108
|
+
- spec/dummy/config/database.yml
|
109
|
+
- spec/dummy/config/environment.rb
|
110
|
+
- spec/dummy/config/environments/development.rb
|
111
|
+
- spec/dummy/config/environments/production.rb
|
112
|
+
- spec/dummy/config/environments/test.rb
|
113
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
114
|
+
- spec/dummy/config/initializers/inflections.rb
|
115
|
+
- spec/dummy/config/initializers/mime_types.rb
|
116
|
+
- spec/dummy/config/initializers/secret_token.rb
|
117
|
+
- spec/dummy/config/initializers/session_store.rb
|
118
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
119
|
+
- spec/dummy/config/locales/en.yml
|
120
|
+
- spec/dummy/config/routes.rb
|
121
|
+
- spec/dummy/config.ru
|
122
|
+
- spec/dummy/db/development.sqlite3
|
123
|
+
- spec/dummy/db/test.sqlite3
|
124
|
+
- spec/dummy/log/development.log
|
125
|
+
- spec/dummy/log/test.log
|
126
|
+
- spec/dummy/public/404.html
|
127
|
+
- spec/dummy/public/422.html
|
128
|
+
- spec/dummy/public/500.html
|
129
|
+
- spec/dummy/public/favicon.ico
|
130
|
+
- spec/dummy/Rakefile
|
131
|
+
- spec/dummy/README.rdoc
|
132
|
+
- spec/dummy/script/rails
|
133
|
+
- spec/resources/jpg_test.jpg
|
134
|
+
- spec/routing/assets_routing_spec.rb
|
135
|
+
- spec/spec_helper.rb
|
136
|
+
- spec/support/book.rb
|
137
|
+
- spec/support/books_asset.rb
|
138
|
+
- spec/support/books_assets_controller.rb
|
139
|
+
- spec/support/books_assets_test_doc.rb
|
140
|
+
homepage: ''
|
141
|
+
licenses: []
|
142
|
+
post_install_message:
|
143
|
+
rdoc_options: []
|
144
|
+
require_paths:
|
145
|
+
- lib
|
146
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
147
|
+
none: false
|
148
|
+
requirements:
|
149
|
+
- - ! '>='
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
segments:
|
153
|
+
- 0
|
154
|
+
hash: 1831344831079520678
|
155
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
|
+
none: false
|
157
|
+
requirements:
|
158
|
+
- - ! '>='
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
segments:
|
162
|
+
- 0
|
163
|
+
hash: 1831344831079520678
|
164
|
+
requirements: []
|
165
|
+
rubyforge_project:
|
166
|
+
rubygems_version: 1.8.10
|
167
|
+
signing_key:
|
168
|
+
specification_version: 3
|
169
|
+
summary: Manage multiple assets related to a specific model
|
170
|
+
test_files:
|
171
|
+
- spec/acts_as_assets_spec.rb
|
172
|
+
- spec/controllers/assets_controller_spec.rb
|
173
|
+
- spec/dummy/app/assets/javascripts/application.js
|
174
|
+
- spec/dummy/app/assets/stylesheets/application.css
|
175
|
+
- spec/dummy/app/controllers/application_controller.rb
|
176
|
+
- spec/dummy/app/helpers/application_helper.rb
|
177
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
178
|
+
- spec/dummy/config/application.rb
|
179
|
+
- spec/dummy/config/boot.rb
|
180
|
+
- spec/dummy/config/database.yml
|
181
|
+
- spec/dummy/config/environment.rb
|
182
|
+
- spec/dummy/config/environments/development.rb
|
183
|
+
- spec/dummy/config/environments/production.rb
|
184
|
+
- spec/dummy/config/environments/test.rb
|
185
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
186
|
+
- spec/dummy/config/initializers/inflections.rb
|
187
|
+
- spec/dummy/config/initializers/mime_types.rb
|
188
|
+
- spec/dummy/config/initializers/secret_token.rb
|
189
|
+
- spec/dummy/config/initializers/session_store.rb
|
190
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
191
|
+
- spec/dummy/config/locales/en.yml
|
192
|
+
- spec/dummy/config/routes.rb
|
193
|
+
- spec/dummy/config.ru
|
194
|
+
- spec/dummy/db/development.sqlite3
|
195
|
+
- spec/dummy/db/test.sqlite3
|
196
|
+
- spec/dummy/log/development.log
|
197
|
+
- spec/dummy/log/test.log
|
198
|
+
- spec/dummy/public/404.html
|
199
|
+
- spec/dummy/public/422.html
|
200
|
+
- spec/dummy/public/500.html
|
201
|
+
- spec/dummy/public/favicon.ico
|
202
|
+
- spec/dummy/Rakefile
|
203
|
+
- spec/dummy/README.rdoc
|
204
|
+
- spec/dummy/script/rails
|
205
|
+
- spec/resources/jpg_test.jpg
|
206
|
+
- spec/routing/assets_routing_spec.rb
|
207
|
+
- spec/spec_helper.rb
|
208
|
+
- spec/support/book.rb
|
209
|
+
- spec/support/books_asset.rb
|
210
|
+
- spec/support/books_assets_controller.rb
|
211
|
+
- spec/support/books_assets_test_doc.rb
|