enju_inventory 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +3 -0
  3. data/Rakefile +36 -0
  4. data/app/controllers/inventories_controller.rb +8 -0
  5. data/app/controllers/inventory_files_controller.rb +83 -0
  6. data/app/models/inventory.rb +25 -0
  7. data/app/models/inventory_file.rb +49 -0
  8. data/app/views/inventories/edit.html.erb +33 -0
  9. data/app/views/inventories/index.html.erb +34 -0
  10. data/app/views/inventories/new.html.erb +32 -0
  11. data/app/views/inventories/show.html.erb +29 -0
  12. data/app/views/inventory_files/edit.html.erb +45 -0
  13. data/app/views/inventory_files/index.html.erb +39 -0
  14. data/app/views/inventory_files/new.html.erb +25 -0
  15. data/app/views/inventory_files/show.html.erb +44 -0
  16. data/config/routes.rb +4 -0
  17. data/db/migrate/20081117143156_create_inventory_files.rb +20 -0
  18. data/db/migrate/20081117143455_create_inventories.rb +17 -0
  19. data/db/migrate/20090706125521_add_attachments_inventory_to_inventory_file.rb +15 -0
  20. data/lib/enju_inventory.rb +4 -0
  21. data/lib/enju_inventory/engine.rb +11 -0
  22. data/lib/enju_inventory/version.rb +3 -0
  23. data/lib/tasks/enju_inventory_tasks.rake +4 -0
  24. data/spec/controllers/inventories_controller_spec.rb +162 -0
  25. data/spec/controllers/inventory_files_controller_spec.rb +289 -0
  26. data/spec/dummy/Rakefile +7 -0
  27. data/spec/dummy/app/assets/javascripts/application.js +9 -0
  28. data/spec/dummy/app/assets/stylesheets/application.css +7 -0
  29. data/spec/dummy/app/controllers/application_controller.rb +65 -0
  30. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  31. data/spec/dummy/app/models/ability.rb +18 -0
  32. data/spec/dummy/app/models/item.rb +20 -0
  33. data/spec/dummy/app/models/role.rb +5 -0
  34. data/spec/dummy/app/models/user.rb +28 -0
  35. data/spec/dummy/app/models/user_has_role.rb +4 -0
  36. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  37. data/spec/dummy/app/views/page/403.html.erb +9 -0
  38. data/spec/dummy/app/views/page/403.mobile.erb +5 -0
  39. data/spec/dummy/app/views/page/403.xml.erb +4 -0
  40. data/spec/dummy/app/views/page/404.html.erb +9 -0
  41. data/spec/dummy/app/views/page/404.mobile.erb +5 -0
  42. data/spec/dummy/app/views/page/404.xml.erb +4 -0
  43. data/spec/dummy/config.ru +4 -0
  44. data/spec/dummy/config/application.rb +45 -0
  45. data/spec/dummy/config/boot.rb +10 -0
  46. data/spec/dummy/config/database.yml +25 -0
  47. data/spec/dummy/config/environment.rb +5 -0
  48. data/spec/dummy/config/environments/development.rb +30 -0
  49. data/spec/dummy/config/environments/production.rb +60 -0
  50. data/spec/dummy/config/environments/test.rb +39 -0
  51. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  52. data/spec/dummy/config/initializers/devise.rb +209 -0
  53. data/spec/dummy/config/initializers/inflections.rb +10 -0
  54. data/spec/dummy/config/initializers/mime_types.rb +6 -0
  55. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  56. data/spec/dummy/config/initializers/session_store.rb +8 -0
  57. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  58. data/spec/dummy/config/locales/en.yml +5 -0
  59. data/spec/dummy/config/routes.rb +60 -0
  60. data/spec/dummy/db/migrate/006_create_items.rb +36 -0
  61. data/spec/dummy/db/migrate/20111201121844_create_roles.rb +12 -0
  62. data/spec/dummy/db/migrate/20111201155456_create_users.rb +13 -0
  63. data/spec/dummy/db/migrate/20111201155513_add_devise_to_users.rb +31 -0
  64. data/spec/dummy/db/migrate/20111201163718_create_user_has_roles.rb +10 -0
  65. data/spec/dummy/db/schema.rb +113 -0
  66. data/spec/dummy/db/test.sqlite3 +0 -0
  67. data/spec/dummy/log/test.log +8481 -0
  68. data/spec/dummy/private/system/inventories/4/original/inventory_file_sample.tsv +7 -0
  69. data/spec/dummy/public/404.html +26 -0
  70. data/spec/dummy/public/422.html +26 -0
  71. data/spec/dummy/public/500.html +26 -0
  72. data/spec/dummy/public/favicon.ico +0 -0
  73. data/spec/dummy/script/rails +6 -0
  74. data/spec/factories/user.rb +31 -0
  75. data/spec/fixtures/inventories.yml +26 -0
  76. data/spec/fixtures/inventory_files.yml +43 -0
  77. data/spec/fixtures/roles.yml +21 -0
  78. data/spec/fixtures/user_has_roles.yml +41 -0
  79. data/spec/fixtures/users.yml +69 -0
  80. data/spec/models/inventory_file_spec.rb +32 -0
  81. data/spec/models/inventory_spec.rb +20 -0
  82. data/spec/spec_helper.rb +33 -0
  83. data/spec/support/controller_macros.rb +48 -0
  84. data/spec/support/devise.rb +4 -0
  85. metadata +311 -0
@@ -0,0 +1,25 @@
1
+ <div id="content_detail" class="ui-corner-all">
2
+ <h1 class="title"><%= t('page.new', :model => t('activerecord.models.inventory_file')) -%> </h1>
3
+ <div id="content_list">
4
+
5
+ <%= form_for(@inventory_file, :html => {:multipart => true}) do |f| -%>
6
+ <%= f.error_messages -%>
7
+
8
+ <div class="field">
9
+ <%= f.label t('page.file') -%><br />
10
+ <%= f.file_field :inventory -%>
11
+ </div>
12
+
13
+ <div class="actions">
14
+ <%= f.submit %>
15
+ </div>
16
+ <%- end -%>
17
+
18
+ </div>
19
+ </div>
20
+
21
+ <div id="submenu" class="ui-corner-all">
22
+ <ul>
23
+ <li><%= link_to t('page.back'), inventory_files_path -%> </li>
24
+ </ul>
25
+ </div>
@@ -0,0 +1,44 @@
1
+ <div id="content_detail" class="ui-corner-all">
2
+ <h1 class="title"><%= t('page.showing', :model => t('activerecord.models.inventory_file')) -%></h1>
3
+ <div id="content_list">
4
+ <p id="notice"><%= notice %></p>
5
+
6
+ <p>
7
+ <strong><%= t('activerecord.attributes.inventory_file.inventory_file_name') -%> :</strong>
8
+ <%= @inventory_file.inventory_file_name -%>
9
+ </p>
10
+
11
+ <p>
12
+ <strong><%= t('activerecord.attributes.inventory_file.inventory_content_type') -%> :</strong>
13
+ <%= @inventory_file.inventory_content_type -%>
14
+ </p>
15
+
16
+ <p>
17
+ <strong><%= t('activerecord.attributes.inventory_file.inventory_file_size') -%> :</strong>
18
+ <%= @inventory_file.inventory_file_size -%>
19
+ </p>
20
+
21
+ <p>
22
+ <strong><%= t('activerecord.attributes.inventory_file.file_hash') -%> :</strong>
23
+ <%= @inventory_file.file_hash -%>
24
+ </p>
25
+
26
+ <p>
27
+ <strong><%= t('activerecord.models.user') -%> :</strong>
28
+ <%= link_to @inventory_file.user.username, @inventory_file.user -%>
29
+ </p>
30
+
31
+ <p>
32
+ <strong><%= t('activerecord.attributes.inventory_file.note') -%> :</strong>
33
+ <%= @inventory_file.note -%>
34
+ </p>
35
+
36
+ </div>
37
+ </div>
38
+
39
+ <div id="submenu" class="ui-corner-all">
40
+ <ul>
41
+ <li><%= link_to t('page.edit'), edit_inventory_file_path(@inventory_file) -%> </li>
42
+ <li><%= back_to_index(flash[:page_info]) -%> </li>
43
+ </ul>
44
+ </div>
data/config/routes.rb ADDED
@@ -0,0 +1,4 @@
1
+ Rails.application.routes.draw do
2
+ resources :inventory_files
3
+ resources :inventories
4
+ end
@@ -0,0 +1,20 @@
1
+ class CreateInventoryFiles < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :inventory_files do |t|
4
+ t.string :filename
5
+ t.string :content_type
6
+ t.integer :size
7
+ t.string :file_hash
8
+ t.integer :user_id
9
+ t.text :note
10
+
11
+ t.timestamps
12
+ end
13
+ add_index :inventory_files, :user_id
14
+ add_index :inventory_files, :file_hash
15
+ end
16
+
17
+ def self.down
18
+ drop_table :inventory_files
19
+ end
20
+ end
@@ -0,0 +1,17 @@
1
+ class CreateInventories < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :inventories do |t|
4
+ t.integer :item_id
5
+ t.integer :inventory_file_id
6
+ t.text :note
7
+
8
+ t.timestamps
9
+ end
10
+ add_index :inventories, :item_id
11
+ add_index :inventories, :inventory_file_id
12
+ end
13
+
14
+ def self.down
15
+ drop_table :inventories
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+ class AddAttachmentsInventoryToInventoryFile < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :inventory_files, :inventory_file_name, :string
4
+ add_column :inventory_files, :inventory_content_type, :string
5
+ add_column :inventory_files, :inventory_file_size, :integer
6
+ add_column :inventory_files, :inventory_updated_at, :datetime
7
+ end
8
+
9
+ def self.down
10
+ remove_column :inventory_files, :inventory_file_name
11
+ remove_column :inventory_files, :inventory_content_type
12
+ remove_column :inventory_files, :inventory_file_size
13
+ remove_column :inventory_files, :inventory_updated_at
14
+ end
15
+ end
@@ -0,0 +1,4 @@
1
+ require "enju_inventory/engine"
2
+
3
+ module EnjuInventory
4
+ end
@@ -0,0 +1,11 @@
1
+ require 'devise'
2
+ require 'cancan'
3
+ require 'paperclip'
4
+ require 'inherited_resources'
5
+ require 'will_paginate'
6
+ require 'sunspot_rails'
7
+
8
+ module EnjuInventory
9
+ class Engine < Rails::Engine
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module EnjuInventory
2
+ VERSION = "0.0.3"
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :enju_inventory do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,162 @@
1
+ require 'spec_helper'
2
+
3
+ describe InventoriesController do
4
+ fixtures :all
5
+
6
+ describe "GET index" do
7
+ describe "When logged in as Administrator" do
8
+ login_admin
9
+
10
+ it "assigns all inventories as @inventories" do
11
+ get :index
12
+ assigns(:inventories).should eq(Inventory.page(1))
13
+ response.should be_success
14
+ end
15
+ end
16
+
17
+ describe "When logged in as Librarian" do
18
+ login_librarian
19
+
20
+ it "assigns all inventories as @inventories" do
21
+ get :index
22
+ assigns(:inventories).should eq(Inventory.page(1))
23
+ response.should be_success
24
+ end
25
+ end
26
+
27
+ describe "When logged in as User" do
28
+ login_user
29
+
30
+ it "assigns all empty as @inventories" do
31
+ get :index
32
+ assigns(:inventories).should be_empty
33
+ response.should be_forbidden
34
+ end
35
+ end
36
+
37
+ describe "When not logged in" do
38
+ it "assigns all inventories as @inventories" do
39
+ get :index
40
+ assigns(:inventories).should be_empty
41
+ response.should redirect_to(new_user_session_url)
42
+ end
43
+ end
44
+ end
45
+
46
+ describe "GET show" do
47
+ describe "When logged in as Administrator" do
48
+ login_admin
49
+
50
+ it "assigns the requested inventory as @inventory" do
51
+ get :show, :id => 1
52
+ assigns(:inventory).should eq(Inventory.find(1))
53
+ end
54
+ end
55
+
56
+ describe "When logged in as Librarian" do
57
+ login_librarian
58
+
59
+ it "assigns the requested inventory as @inventory" do
60
+ get :show, :id => 1
61
+ assigns(:inventory).should eq(Inventory.find(1))
62
+ end
63
+ end
64
+
65
+ describe "When logged in as User" do
66
+ login_user
67
+
68
+ it "assigns the requested inventory as @inventory" do
69
+ get :show, :id => 1
70
+ assigns(:inventory).should eq(Inventory.find(1))
71
+ end
72
+ end
73
+
74
+ describe "When not logged in" do
75
+ it "assigns the requested inventory as @inventory" do
76
+ get :show, :id => 1
77
+ assigns(:inventory).should eq(Inventory.find(1))
78
+ response.should redirect_to(new_user_session_url)
79
+ end
80
+ end
81
+ end
82
+
83
+ describe "GET new" do
84
+ describe "When logged in as Administrator" do
85
+ login_admin
86
+
87
+ it "assigns the requested inventory as @inventory" do
88
+ get :new
89
+ assigns(:inventory).should_not be_valid
90
+ response.should be_success
91
+ end
92
+ end
93
+
94
+ describe "When logged in as Librarian" do
95
+ login_librarian
96
+
97
+ it "should not assign the requested inventory as @inventory" do
98
+ get :new
99
+ assigns(:inventory).should_not be_valid
100
+ response.should be_success
101
+ end
102
+ end
103
+
104
+ describe "When logged in as User" do
105
+ login_user
106
+
107
+ it "should not assign the requested inventory as @inventory" do
108
+ get :new
109
+ assigns(:inventory).should_not be_valid
110
+ response.should be_forbidden
111
+ end
112
+ end
113
+
114
+ describe "When not logged in" do
115
+ it "should not assign the requested inventory as @inventory" do
116
+ get :new
117
+ assigns(:inventory).should_not be_valid
118
+ response.should redirect_to(new_user_session_url)
119
+ end
120
+ end
121
+ end
122
+
123
+ describe "GET edit" do
124
+ describe "When logged in as Administrator" do
125
+ login_admin
126
+
127
+ it "assigns the requested inventory as @inventory" do
128
+ inventory = inventories(:inventory_00001)
129
+ get :edit, :id => inventory.id
130
+ assigns(:inventory).should eq(inventory)
131
+ end
132
+ end
133
+
134
+ describe "When logged in as Librarian" do
135
+ login_librarian
136
+
137
+ it "assigns the requested inventory as @inventory" do
138
+ inventory = inventories(:inventory_00001)
139
+ get :edit, :id => inventory.id
140
+ assigns(:inventory).should eq(inventory)
141
+ end
142
+ end
143
+
144
+ describe "When logged in as User" do
145
+ login_user
146
+
147
+ it "assigns the requested inventory as @inventory" do
148
+ inventory = inventories(:inventory_00001)
149
+ get :edit, :id => inventory.id
150
+ response.should be_forbidden
151
+ end
152
+ end
153
+
154
+ describe "When not logged in" do
155
+ it "should not assign the requested inventory as @inventory" do
156
+ inventory = inventories(:inventory_00001)
157
+ get :edit, :id => inventory.id
158
+ response.should redirect_to(new_user_session_url)
159
+ end
160
+ end
161
+ end
162
+ end
@@ -0,0 +1,289 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe InventoryFilesController do
5
+ fixtures :all
6
+
7
+ describe "GET index" do
8
+ describe "When logged in as Administrator" do
9
+ login_admin
10
+
11
+ it "assigns all inventory_files as @inventory_files" do
12
+ get :index
13
+ assigns(:inventory_files).should eq(InventoryFile.page(1))
14
+ end
15
+ end
16
+
17
+ describe "When logged in as Librarian" do
18
+ login_librarian
19
+
20
+ it "assigns all inventory_files as @inventory_files" do
21
+ get :index
22
+ assigns(:inventory_files).should eq(InventoryFile.page(1))
23
+ end
24
+ end
25
+
26
+ describe "When logged in as User" do
27
+ login_user
28
+
29
+ it "assigns empty as @inventory_files" do
30
+ get :index
31
+ assigns(:inventory_files).should be_empty
32
+ response.should be_forbidden
33
+ end
34
+ end
35
+
36
+ describe "When not logged in" do
37
+ it "assigns empty as @inventory_files" do
38
+ get :index
39
+ assigns(:inventory_files).should be_empty
40
+ response.should redirect_to(new_user_session_url)
41
+ end
42
+ end
43
+ end
44
+
45
+ describe "GET show" do
46
+ describe "When logged in as Administrator" do
47
+ login_admin
48
+
49
+ it "assigns the requested inventory_file as @inventory_file" do
50
+ get :show, :id => 1
51
+ assigns(:inventory_file).should eq(InventoryFile.find(1))
52
+ end
53
+ end
54
+
55
+ describe "When logged in as Librarian" do
56
+ login_librarian
57
+
58
+ it "assigns the requested inventory_file as @inventory_file" do
59
+ get :show, :id => 1
60
+ assigns(:inventory_file).should eq(InventoryFile.find(1))
61
+ end
62
+ end
63
+
64
+ describe "When logged in as User" do
65
+ login_user
66
+
67
+ it "assigns the requested inventory_file as @inventory_file" do
68
+ get :show, :id => 1
69
+ assigns(:inventory_file).should eq(InventoryFile.find(1))
70
+ end
71
+ end
72
+
73
+ describe "When not logged in" do
74
+ it "assigns the requested inventory_file as @inventory_file" do
75
+ get :show, :id => 1
76
+ assigns(:inventory_file).should eq(InventoryFile.find(1))
77
+ response.should redirect_to(new_user_session_url)
78
+ end
79
+ end
80
+ end
81
+
82
+ describe "GET new" do
83
+ describe "When logged in as Administrator" do
84
+ login_admin
85
+
86
+ it "assigns the requested inventory_file as @inventory_file" do
87
+ get :new
88
+ assigns(:inventory_file).should_not be_valid
89
+ response.should be_success
90
+ end
91
+ end
92
+
93
+ describe "When logged in as Librarian" do
94
+ login_librarian
95
+
96
+ it "should not assign the requested inventory_file as @inventory_file" do
97
+ get :new
98
+ assigns(:inventory_file).should_not be_valid
99
+ response.should be_success
100
+ end
101
+ end
102
+
103
+ describe "When logged in as User" do
104
+ login_user
105
+
106
+ it "should not assign the requested inventory_file as @inventory_file" do
107
+ get :new
108
+ assigns(:inventory_file).should_not be_valid
109
+ response.should be_forbidden
110
+ end
111
+ end
112
+
113
+ describe "When not logged in" do
114
+ it "should not assign the requested inventory_file as @inventory_file" do
115
+ get :new
116
+ assigns(:inventory_file).should_not be_valid
117
+ response.should redirect_to(new_user_session_url)
118
+ end
119
+ end
120
+ end
121
+
122
+ describe "POST create" do
123
+ describe "When logged in as Librarian" do
124
+ before(:each) do
125
+ @user = FactoryGirl.create(:librarian)
126
+ sign_in @user
127
+ end
128
+
129
+ it "should create inventory_file" do
130
+ post :create, :inventory_file => {:inventory => fixture_file_upload("/../../examples/inventory_file_sample.tsv", 'text/csv') }
131
+ assigns(:inventory_file).save!
132
+ assigns(:inventory_file).should be_valid
133
+ assigns(:inventory_file).user.username.should eq @user.username
134
+ response.should redirect_to inventory_file_url(assigns(:inventory_file))
135
+ end
136
+ end
137
+
138
+ describe "When logged in as User" do
139
+ before(:each) do
140
+ @user = FactoryGirl.create(:user)
141
+ sign_in @user
142
+ end
143
+
144
+ it "should be forbidden" do
145
+ post :create, :inventory_file => {:inventory => fixture_file_upload("/../../examples/inventory_file_sample.tsv", 'text/csv') }
146
+ response.should be_forbidden
147
+ end
148
+ end
149
+
150
+ describe "When not logged in" do
151
+ it "should be redirect to new session url" do
152
+ post :create, :inventory_file => {:inventory => fixture_file_upload("/../../examples/inventory_file_sample.tsv", 'text/csv') }
153
+ response.should redirect_to new_user_session_url
154
+ end
155
+ end
156
+ end
157
+
158
+ describe "GET edit" do
159
+ describe "When logged in as Administrator" do
160
+ login_admin
161
+
162
+ it "assigns the requested inventory_file as @inventory_file" do
163
+ inventory_file = inventory_files(:inventory_file_00001)
164
+ get :edit, :id => inventory_file.id
165
+ assigns(:inventory_file).should eq(inventory_file)
166
+ end
167
+ end
168
+
169
+ describe "When logged in as Librarian" do
170
+ login_librarian
171
+
172
+ it "assigns the requested inventory_file as @inventory_file" do
173
+ inventory_file = inventory_files(:inventory_file_00001)
174
+ get :edit, :id => inventory_file.id
175
+ assigns(:inventory_file).should eq(inventory_file)
176
+ end
177
+ end
178
+
179
+ describe "When logged in as User" do
180
+ login_user
181
+
182
+ it "assigns the requested inventory_file as @inventory_file" do
183
+ inventory_file = inventory_files(:inventory_file_00001)
184
+ get :edit, :id => inventory_file.id
185
+ response.should be_forbidden
186
+ end
187
+ end
188
+
189
+ describe "When not logged in" do
190
+ it "should not assign the requested inventory_file as @inventory_file" do
191
+ inventory_file = inventory_files(:inventory_file_00001)
192
+ get :edit, :id => inventory_file.id
193
+ response.should redirect_to(new_user_session_url)
194
+ end
195
+ end
196
+ end
197
+
198
+ describe "PUT update" do
199
+ describe "When logged in as Administrator" do
200
+ login_admin
201
+
202
+ it "should update inventory_file" do
203
+ put :update, :id => inventory_files(:inventory_file_00003).id, :inventory_file => { }
204
+ response.should redirect_to inventory_file_url(assigns(:inventory_file))
205
+ end
206
+ end
207
+
208
+ describe "When logged in as Librarian" do
209
+ login_librarian
210
+
211
+ it "should update inventory_file" do
212
+ put :update, :id => inventory_files(:inventory_file_00003).id, :inventory_file => { }
213
+ response.should redirect_to inventory_file_url(assigns(:inventory_file))
214
+ end
215
+ end
216
+
217
+ describe "When logged in as User" do
218
+ login_user
219
+
220
+ it "should not update inventory_file" do
221
+ put :update, :id => inventory_files(:inventory_file_00003).id, :inventory_file => { }
222
+ response.should be_forbidden
223
+ end
224
+ end
225
+
226
+ describe "When not logged in" do
227
+ it "should not update inventory_file" do
228
+ put :update, :id => inventory_files(:inventory_file_00003).id, :inventory_file => { }
229
+ response.should redirect_to new_user_session_url
230
+ end
231
+ end
232
+ end
233
+
234
+ describe "DELETE destroy" do
235
+ before(:each) do
236
+ @inventory_file = inventory_files(:inventory_file_00001)
237
+ end
238
+
239
+ describe "When logged in as Administrator" do
240
+ login_admin
241
+
242
+ it "destroys the requested inventory_file" do
243
+ delete :destroy, :id => @inventory_file.id
244
+ end
245
+
246
+ it "redirects to the inventory_files list" do
247
+ delete :destroy, :id => @inventory_file.id
248
+ response.should redirect_to(inventory_files_url)
249
+ end
250
+ end
251
+
252
+ describe "When logged in as Librarian" do
253
+ login_librarian
254
+
255
+ it "destroys the requested inventory_file" do
256
+ delete :destroy, :id => @inventory_file.id
257
+ end
258
+
259
+ it "redirects to the inventory_files list" do
260
+ delete :destroy, :id => @inventory_file.id
261
+ response.should redirect_to(inventory_files_url)
262
+ end
263
+ end
264
+
265
+ describe "When logged in as User" do
266
+ login_user
267
+
268
+ it "destroys the requested inventory_file" do
269
+ delete :destroy, :id => @inventory_file.id
270
+ end
271
+
272
+ it "should be forbidden" do
273
+ delete :destroy, :id => @inventory_file.id
274
+ response.should be_forbidden
275
+ end
276
+ end
277
+
278
+ describe "When not logged in" do
279
+ it "destroys the requested inventory_file" do
280
+ delete :destroy, :id => @inventory_file.id
281
+ end
282
+
283
+ it "should be forbidden" do
284
+ delete :destroy, :id => @inventory_file.id
285
+ response.should redirect_to(new_user_session_url)
286
+ end
287
+ end
288
+ end
289
+ end