acts_as_assets 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,12 +6,12 @@ describe Books::AssetsController do
6
6
  :controller => "books/assets", :action => :index, :book_id => 1, :type => "TestDoc")}
7
7
 
8
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"])}
9
+ :controller => "books/assets", :action => :index, :book_id => 1, :type => "my/asset/type")}
10
10
 
11
11
  it {should route(:post,'books/1/assets/TestDoc.js').to(
12
12
  :controller => "books/assets", :action => :create, :book_id => 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, :book_id => 1, :format => 'js', :id => 20)}
15
+ :controller => "books/assets", :action => :destroy, :book_id => 1, :format => 'js', :asset_id => 20)}
16
16
 
17
17
  end
@@ -0,0 +1,29 @@
1
+ require "spec_helper"
2
+
3
+ describe "Rspec Matchers" do
4
+
5
+ describe "act_as_asset" do
6
+ context "given a model that acts_as_assets" do
7
+ subject{Books::Asset.new}
8
+ it{should act_as_assets}
9
+ end
10
+
11
+ context "given a model that does not acts_as_assets" do
12
+ subject{Book.new}
13
+ it{should_not act_as_assets}
14
+ end
15
+ end
16
+
17
+ describe "act_as_unique_asset" do
18
+ context "given a model that include unique asset" do
19
+ subject{Books::Assets::UniqueTestDoc.new}
20
+ it{should act_as_unique_asset}
21
+ end
22
+
23
+ context "given a model that does not include module unique asset" do
24
+ subject{Books::Assets::TestDoc.new}
25
+ it{should_not act_as_unique_asset}
26
+ end
27
+ end
28
+
29
+ end
data/spec/spec_helper.rb CHANGED
@@ -44,6 +44,14 @@ RSpec.configure do |config|
44
44
 
45
45
  end
46
46
 
47
+ #destroy created assets
48
+ config.before :all do
49
+ @dtbd = []
50
+ end
51
+ config.after :all do
52
+ @dtbd.each {|d| d.destroy unless d.nil? }
53
+ end
54
+
47
55
  config.before(:each) do
48
56
  Books::Asset.delete_all
49
57
  Book.delete_all
@@ -0,0 +1,7 @@
1
+ module Books
2
+ module Assets
3
+ class UniqueTestDoc < Books::Asset
4
+ include ActsAsAssets::UniqueAsset
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,43 @@
1
+ require "spec_helper"
2
+
3
+ describe ActsAsAssets::UniqueAsset do
4
+ let(:book) { Book.create!(:title => "my new book") }
5
+
6
+ context "creating 2 assets of the same type related to the same resource" do
7
+ before do
8
+ @book = book
9
+ end
10
+
11
+ context "and asset include the model UniqAsset" do
12
+
13
+ it "should fail on the creation of the second asset" do
14
+ asset1 = Books::Assets::UniqueTestDoc.create! :book => @book
15
+ @dtbd << asset1
16
+ asset2 = Books::Assets::UniqueTestDoc.new :book => @book
17
+ @dtbd << asset2
18
+ asset2.save
19
+
20
+ asset2.should_not be_valid
21
+ asset2.should have(1).error_on("Books::Assets::UniqueTestDoc")
22
+ end
23
+
24
+ end
25
+
26
+ context "and asset does not include the model UniqAsset" do
27
+
28
+ it "should fail on the creation of the second asset" do
29
+ asset1 = Books::Assets::TestDoc.create! :book => @book
30
+ @dtbd << asset1
31
+ asset2 = Books::Assets::TestDoc.new :book => @book
32
+ @dtbd << asset2
33
+ asset2.save
34
+
35
+ asset2.should be_valid
36
+ asset2.should have(0).error_on("Books::Assets::UniqueTestDoc")
37
+ end
38
+
39
+ end
40
+
41
+ end
42
+
43
+ end
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.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-13 00:00:00.000000000Z
12
+ date: 2012-02-14 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &70134249062460 !ruby/object:Gem::Requirement
16
+ requirement: &70319499869720 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.2.1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70134249062460
24
+ version_requirements: *70319499869720
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: paperclip
27
- requirement: &70134249062040 !ruby/object:Gem::Requirement
27
+ requirement: &70319499869300 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70134249062040
35
+ version_requirements: *70319499869300
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: sqlite3
38
- requirement: &70134249061580 !ruby/object:Gem::Requirement
38
+ requirement: &70319499868840 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70134249061580
46
+ version_requirements: *70319499868840
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec-rails
49
- requirement: &70134249061160 !ruby/object:Gem::Requirement
49
+ requirement: &70319499868420 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70134249061160
57
+ version_requirements: *70319499868420
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: paperclip
60
- requirement: &70134249060740 !ruby/object:Gem::Requirement
60
+ requirement: &70319499868000 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70134249060740
68
+ version_requirements: *70319499868000
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: shoulda-matchers
71
- requirement: &70134249060320 !ruby/object:Gem::Requirement
71
+ requirement: &70319499867580 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70134249060320
79
+ version_requirements: *70319499867580
80
80
  description: ''
81
81
  email:
82
82
  - acampolonghi@gmail.com
@@ -85,12 +85,17 @@ extensions: []
85
85
  extra_rdoc_files: []
86
86
  files:
87
87
  - app/controllers/acts_as_assets/assets_controller.rb
88
+ - app/helpers/acts_as_assets/assets_helper.rb
89
+ - app/views/acts_as_assets/assets/create.js.erb
88
90
  - app/views/acts_as_assets/assets/destroy.js.erb
89
91
  - app/views/acts_as_assets/assets/index.html.erb
92
+ - config/locales/it.yml
90
93
  - config/routes.rb
91
94
  - lib/acts_as_assets/base.rb
92
95
  - lib/acts_as_assets/engine.rb
93
- - lib/acts_as_assets/interpolations.rb
96
+ - lib/acts_as_assets/matchers/rspec.rb
97
+ - lib/acts_as_assets/paperclip/interpolations.rb
98
+ - lib/acts_as_assets/unique_asset.rb
94
99
  - lib/acts_as_assets/version.rb
95
100
  - lib/acts_as_assets.rb
96
101
  - lib/tasks/acts_as_assets_tasks.rake
@@ -120,7 +125,6 @@ files:
120
125
  - spec/dummy/config/routes.rb
121
126
  - spec/dummy/config.ru
122
127
  - spec/dummy/db/development.sqlite3
123
- - spec/dummy/db/test.sqlite3
124
128
  - spec/dummy/log/development.log
125
129
  - spec/dummy/log/test.log
126
130
  - spec/dummy/public/404.html
@@ -132,11 +136,14 @@ files:
132
136
  - spec/dummy/script/rails
133
137
  - spec/resources/jpg_test.jpg
134
138
  - spec/routing/assets_routing_spec.rb
139
+ - spec/rspec_matchers_spec.rb
135
140
  - spec/spec_helper.rb
136
141
  - spec/support/book.rb
137
142
  - spec/support/books_asset.rb
138
143
  - spec/support/books_assets_controller.rb
139
144
  - spec/support/books_assets_test_doc.rb
145
+ - spec/support/books_assets_unique_test_doc.rb
146
+ - spec/unique_asset_spec.rb
140
147
  homepage: ''
141
148
  licenses: []
142
149
  post_install_message:
@@ -151,7 +158,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
151
158
  version: '0'
152
159
  segments:
153
160
  - 0
154
- hash: 1831344831079520678
161
+ hash: 917527614412971072
155
162
  required_rubygems_version: !ruby/object:Gem::Requirement
156
163
  none: false
157
164
  requirements:
@@ -160,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
160
167
  version: '0'
161
168
  segments:
162
169
  - 0
163
- hash: 1831344831079520678
170
+ hash: 917527614412971072
164
171
  requirements: []
165
172
  rubyforge_project:
166
173
  rubygems_version: 1.8.10
@@ -192,7 +199,6 @@ test_files:
192
199
  - spec/dummy/config/routes.rb
193
200
  - spec/dummy/config.ru
194
201
  - spec/dummy/db/development.sqlite3
195
- - spec/dummy/db/test.sqlite3
196
202
  - spec/dummy/log/development.log
197
203
  - spec/dummy/log/test.log
198
204
  - spec/dummy/public/404.html
@@ -204,8 +210,11 @@ test_files:
204
210
  - spec/dummy/script/rails
205
211
  - spec/resources/jpg_test.jpg
206
212
  - spec/routing/assets_routing_spec.rb
213
+ - spec/rspec_matchers_spec.rb
207
214
  - spec/spec_helper.rb
208
215
  - spec/support/book.rb
209
216
  - spec/support/books_asset.rb
210
217
  - spec/support/books_assets_controller.rb
211
218
  - spec/support/books_assets_test_doc.rb
219
+ - spec/support/books_assets_unique_test_doc.rb
220
+ - spec/unique_asset_spec.rb
Binary file