enju_trunk_message 0.1.14.pre3
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +46 -0
- data/app/controllers/message_requests_controller.rb +62 -0
- data/app/controllers/message_templates_controller.rb +17 -0
- data/app/controllers/messages_controller.rb +159 -0
- data/app/helpers/messages_helper.rb +2 -0
- data/app/models/message.rb +85 -0
- data/app/models/message_request.rb +97 -0
- data/app/models/message_template.rb +39 -0
- data/app/views/layouts/messages.html.erb +24 -0
- data/app/views/message_requests/edit.html.erb +40 -0
- data/app/views/message_requests/index.html.erb +58 -0
- data/app/views/message_requests/new.html.erb +40 -0
- data/app/views/message_requests/show.html.erb +55 -0
- data/app/views/message_templates/_form.html.erb +27 -0
- data/app/views/message_templates/edit.html.erb +13 -0
- data/app/views/message_templates/index.html.erb +44 -0
- data/app/views/message_templates/new.html.erb +12 -0
- data/app/views/message_templates/show.html.erb +33 -0
- data/app/views/messages/_form.html.erb +37 -0
- data/app/views/messages/edit.html.erb +42 -0
- data/app/views/messages/index.atom.builder +15 -0
- data/app/views/messages/index.html.erb +66 -0
- data/app/views/messages/index.rss.builder +41 -0
- data/app/views/messages/new.html.erb +43 -0
- data/app/views/messages/show.html.erb +48 -0
- data/app/views/notifier/message_notification.en.text.erb +14 -0
- data/app/views/notifier/message_notification.ja.text.erb +14 -0
- data/config/locales/translation_en.yml +51 -0
- data/config/locales/translation_ja.yml +51 -0
- data/config/routes.rb +9 -0
- data/db/fixtures/message_templates.yml +70 -0
- data/db/migrate/149_create_message_templates.rb +18 -0
- data/db/migrate/154_create_messages.rb +24 -0
- data/db/migrate/20080819181903_create_message_requests.rb +20 -0
- data/db/migrate/20110913115320_add_lft_and_rgt_to_message.rb +11 -0
- data/db/migrate/20120125050502_add_depth_to_message.rb +6 -0
- data/lib/enju_message.rb +7 -0
- data/lib/enju_message/engine.rb +10 -0
- data/lib/enju_message/user.rb +28 -0
- data/lib/enju_message/version.rb +3 -0
- data/lib/generators/enju_message/views_generator.rb +21 -0
- data/lib/tasks/enju_message_tasks.rake +5 -0
- data/spec/controllers/message_requests_controller_spec.rb +275 -0
- data/spec/controllers/message_templates_controller_spec.rb +439 -0
- data/spec/controllers/messages_controller_spec.rb +443 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +9 -0
- data/spec/dummy/app/assets/stylesheets/application.css +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +52 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/notifier.rb +30 -0
- data/spec/dummy/app/models/ability.rb +30 -0
- data/spec/dummy/app/models/library_group.rb +86 -0
- data/spec/dummy/app/models/patron.rb +167 -0
- data/spec/dummy/app/models/patron_type.rb +19 -0
- data/spec/dummy/app/models/role.rb +8 -0
- data/spec/dummy/app/models/setting.rb +4 -0
- data/spec/dummy/app/models/user.rb +46 -0
- data/spec/dummy/app/models/user_group.rb +2 -0
- data/spec/dummy/app/models/user_has_role.rb +4 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/page/403.html.erb +9 -0
- data/spec/dummy/app/views/page/403.mobile.erb +5 -0
- data/spec/dummy/app/views/page/403.xml.erb +4 -0
- data/spec/dummy/app/views/page/404.html.erb +9 -0
- data/spec/dummy/app/views/page/404.mobile.erb +5 -0
- data/spec/dummy/app/views/page/404.xml.erb +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +44 -0
- data/spec/dummy/config/application.yml +38 -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 +30 -0
- data/spec/dummy/config/environments/production.rb +60 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/devise.rb +205 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +6 -0
- data/spec/dummy/config/initializers/resque_mailer.rb +1 -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 +60 -0
- data/spec/dummy/db/migrate/001_create_patrons.rb +62 -0
- data/spec/dummy/db/migrate/080_create_library_groups.rb +25 -0
- data/spec/dummy/db/migrate/20080905191442_create_patron_types.rb +16 -0
- data/spec/dummy/db/migrate/20100211105551_add_admin_networks_to_library_group.rb +9 -0
- data/spec/dummy/db/migrate/20100222124420_add_allow_bookmark_external_url_to_library_group.rb +9 -0
- data/spec/dummy/db/migrate/20100527113752_create_delayed_jobs.rb +21 -0
- data/spec/dummy/db/migrate/20110115022329_add_position_to_library_group.rb +9 -0
- data/spec/dummy/db/migrate/20110222073537_add_url_to_library_group.rb +9 -0
- data/spec/dummy/db/migrate/20111020063828_remove_dsbl_from_library_group.rb +11 -0
- data/spec/dummy/db/migrate/20111201121636_create_languages.rb +16 -0
- data/spec/dummy/db/migrate/20111201121844_create_roles.rb +12 -0
- data/spec/dummy/db/migrate/20111201155456_create_users.rb +14 -0
- data/spec/dummy/db/migrate/20111201155513_add_devise_to_users.rb +52 -0
- data/spec/dummy/db/migrate/20111201163342_create_user_groups.rb +12 -0
- data/spec/dummy/db/migrate/20111201163718_create_user_has_roles.rb +10 -0
- data/spec/dummy/db/migrate/20120213092115_add_queue_to_delayed_jobs.rb +9 -0
- data/spec/dummy/db/schema.rb +236 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/delayed_job +5 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/factories/message.rb +8 -0
- data/spec/factories/message_request.rb +8 -0
- data/spec/factories/message_template.rb +7 -0
- data/spec/factories/user.rb +34 -0
- data/spec/fixtures/library_groups.yml +34 -0
- data/spec/fixtures/message_requests.yml +30 -0
- data/spec/fixtures/message_templates.yml +85 -0
- data/spec/fixtures/messages.yml +62 -0
- data/spec/fixtures/patrons.yml +338 -0
- data/spec/fixtures/roles.yml +21 -0
- data/spec/fixtures/user_groups.yml +25 -0
- data/spec/fixtures/user_has_roles.yml +41 -0
- data/spec/fixtures/users.yml +71 -0
- data/spec/models/message_request_spec.rb +24 -0
- data/spec/models/message_spec.rb +59 -0
- data/spec/models/message_template_spec.rb +22 -0
- data/spec/spec_helper.rb +46 -0
- data/spec/support/controller_macros.rb +48 -0
- data/spec/support/devise.rb +4 -0
- metadata +440 -0
@@ -0,0 +1,443 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MessagesController do
|
4
|
+
fixtures :all
|
5
|
+
|
6
|
+
describe "GET index", :solr => true do
|
7
|
+
before do
|
8
|
+
Message.reindex
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "When logged in as Administrator" do
|
12
|
+
before(:each) do
|
13
|
+
@user = FactoryGirl.create(:admin)
|
14
|
+
sign_in @user
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should get its own messages" do
|
18
|
+
get :index
|
19
|
+
assigns(:messages).should_not be_nil
|
20
|
+
response.should be_success
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "When user_id is specified" do
|
24
|
+
it "assigns all messages as @messages" do
|
25
|
+
get :index, :user_id => @user.username
|
26
|
+
assigns(:messages).should_not be_nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "When logged in as Librarian" do
|
32
|
+
before(:each) do
|
33
|
+
@user = FactoryGirl.create(:librarian)
|
34
|
+
sign_in @user
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should get its own messages" do
|
38
|
+
get :index
|
39
|
+
assigns(:messages).should_not be_nil
|
40
|
+
response.should be_success
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "When user_id is specified" do
|
44
|
+
it "assigns all messages as @messages" do
|
45
|
+
get :index, :user_id => @user.username
|
46
|
+
assigns(:messages).should_not be_nil
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "When logged in as User" do
|
52
|
+
login_fixture_user
|
53
|
+
|
54
|
+
describe "When user_id is specified" do
|
55
|
+
it "assigns all messages as @messages" do
|
56
|
+
get :index
|
57
|
+
assigns(:messages).should_not be_nil
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should get its own messages" do
|
62
|
+
get :index
|
63
|
+
assigns(:messages).should_not be_nil
|
64
|
+
response.should be_success
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should get index with query" do
|
68
|
+
get :index, :query => 'you'
|
69
|
+
assigns(:messages).first.receiver.should eq users(:user1)
|
70
|
+
response.should be_success
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "When not logged in" do
|
75
|
+
it "assigns all messages as @messages" do
|
76
|
+
get :index
|
77
|
+
assigns(:messages).should be_nil
|
78
|
+
response.should redirect_to(new_user_session_url)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "GET show" do
|
84
|
+
describe "When logged in as Administrator" do
|
85
|
+
login_fixture_admin
|
86
|
+
|
87
|
+
it "assigns the requested message as @message" do
|
88
|
+
message = messages(:user1_to_user2_1)
|
89
|
+
get :show, :id => message.id
|
90
|
+
assigns(:message).should eq(message)
|
91
|
+
response.should be_missing
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe "When logged in as Librarian" do
|
96
|
+
login_fixture_librarian
|
97
|
+
|
98
|
+
it "assigns the requested message as @message" do
|
99
|
+
message = messages(:user1_to_user2_1)
|
100
|
+
get :show, :id => message.id
|
101
|
+
assigns(:message).should eq(message)
|
102
|
+
response.should be_forbidden
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe "When logged in as Librarian" do
|
107
|
+
login_fixture_user
|
108
|
+
|
109
|
+
it "should show my message" do
|
110
|
+
get :show, :id => messages(:user2_to_user1_1).id
|
111
|
+
response.should be_success
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should should not show other user's message" do
|
115
|
+
get :show, :id => messages(:user1_to_user2_1).id
|
116
|
+
response.should be_forbidden
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe "When not logged in" do
|
121
|
+
it "assigns the requested message as @message" do
|
122
|
+
get :show, :id => messages(:user1_to_user2_1).id
|
123
|
+
response.should redirect_to new_user_session_url
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
describe "GET new" do
|
129
|
+
describe "When logged in as Administrator" do
|
130
|
+
login_admin
|
131
|
+
|
132
|
+
it "assigns the requested message as @message" do
|
133
|
+
get :new
|
134
|
+
assigns(:message).should_not be_valid
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
describe "When logged in as Librarian" do
|
139
|
+
login_librarian
|
140
|
+
|
141
|
+
it "should not assign the requested message as @message" do
|
142
|
+
get :new
|
143
|
+
assigns(:message).should_not be_valid
|
144
|
+
response.should be_success
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
describe "When logged in as User" do
|
149
|
+
login_fixture_user
|
150
|
+
|
151
|
+
it "should not assign the requested message as @message" do
|
152
|
+
get :new
|
153
|
+
assigns(:message).should_not be_valid
|
154
|
+
response.should be_forbidden
|
155
|
+
end
|
156
|
+
|
157
|
+
it "should not get new template without parent_id" do
|
158
|
+
get :new
|
159
|
+
response.should be_forbidden
|
160
|
+
end
|
161
|
+
|
162
|
+
it "should not get new template with invalid parent_id" do
|
163
|
+
get :new, :parent_id => 1
|
164
|
+
response.should be_forbidden
|
165
|
+
end
|
166
|
+
|
167
|
+
it "should not get new template with valid parent_id" do
|
168
|
+
get :new, :parent_id => 2
|
169
|
+
response.should be_forbidden
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
describe "When not logged in" do
|
174
|
+
it "should not assign the requested message as @message" do
|
175
|
+
get :new
|
176
|
+
assigns(:message).should_not be_valid
|
177
|
+
response.should redirect_to(new_user_session_url)
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
describe "GET edit" do
|
183
|
+
describe "When logged in as Administrator" do
|
184
|
+
login_admin
|
185
|
+
|
186
|
+
it "assigns the requested message as @message" do
|
187
|
+
message = messages(:user1_to_user2_1)
|
188
|
+
get :edit, :id => message.id
|
189
|
+
assigns(:message).should eq(message)
|
190
|
+
response.should be_missing
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
describe "When logged in as Librarian" do
|
195
|
+
login_librarian
|
196
|
+
|
197
|
+
it "assigns the requested message as @message" do
|
198
|
+
message = messages(:user1_to_user2_1)
|
199
|
+
get :edit, :id => message.id
|
200
|
+
assigns(:message).should eq(message)
|
201
|
+
response.should be_forbidden
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
describe "When logged in as User" do
|
206
|
+
login_fixture_user
|
207
|
+
|
208
|
+
it "assigns the requested message as @message" do
|
209
|
+
message = messages(:user1_to_user2_1)
|
210
|
+
get :edit, :id => message.id
|
211
|
+
assigns(:message).should eq(message)
|
212
|
+
response.should be_forbidden
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
describe "When not logged in" do
|
217
|
+
it "assigns the requested message as @message" do
|
218
|
+
message = FactoryGirl.create(:message)
|
219
|
+
get :edit, :id => message.id
|
220
|
+
assigns(:message).should eq(message)
|
221
|
+
response.should redirect_to new_user_session_url
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
describe "POST create" do
|
227
|
+
before(:each) do
|
228
|
+
@attrs = {:recipient => users(:user1).username, :subject => 'test',:body => 'test'}
|
229
|
+
@invalid_attrs = {:recipient => users(:user1).username, :subject => 'test', :body => ''}
|
230
|
+
end
|
231
|
+
|
232
|
+
describe "When logged in as Administrator" do
|
233
|
+
login_admin
|
234
|
+
|
235
|
+
describe "with valid params" do
|
236
|
+
it "assigns a newly created message as @message" do
|
237
|
+
post :create, :message => @attrs, :user_id => users(:user1).username
|
238
|
+
assigns(:message).should be_valid
|
239
|
+
end
|
240
|
+
|
241
|
+
it "redirects to the created message" do
|
242
|
+
post :create, :message => @attrs, :user_id => users(:user1).username
|
243
|
+
response.should redirect_to(messages_url)
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
describe "with invalid params" do
|
248
|
+
it "assigns a newly created but unsaved message as @message" do
|
249
|
+
post :create, :message => @invalid_attrs, :user_id => users(:user1).username
|
250
|
+
assigns(:message).should_not be_valid
|
251
|
+
end
|
252
|
+
|
253
|
+
it "re-renders the 'new' template" do
|
254
|
+
post :create, :message => @invalid_attrs, :user_id => users(:user1).username
|
255
|
+
response.should render_template("new")
|
256
|
+
response.should be_success
|
257
|
+
end
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
describe "When logged in as Librarian" do
|
262
|
+
login_fixture_librarian
|
263
|
+
|
264
|
+
it "should create message without parent_id" do
|
265
|
+
post :create, :message => {:recipient => 'user2', :subject => "test", :body => "test", :parent_id => 2}
|
266
|
+
response.should redirect_to messages_url
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
describe "When logged in as User" do
|
271
|
+
login_fixture_user
|
272
|
+
|
273
|
+
it "should not create message without parent_id" do
|
274
|
+
post :create, :message => {:recipient => 'user2', :subject => "test", :body => "test"}
|
275
|
+
response.should be_forbidden
|
276
|
+
end
|
277
|
+
|
278
|
+
it "should not create message with parent_id" do
|
279
|
+
post :create, :message => {:recipient => 'user2', :subject => "test", :body => "test", :parent_id => 2}
|
280
|
+
response.should be_forbidden
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
describe "When not logged in" do
|
285
|
+
describe "with valid params" do
|
286
|
+
it "assigns a newly created message as @message" do
|
287
|
+
post :create, :message => @attrs
|
288
|
+
assigns(:message).should be_valid
|
289
|
+
end
|
290
|
+
|
291
|
+
it "should redirect to new_user_session_url" do
|
292
|
+
post :create, :message => @attrs
|
293
|
+
response.should redirect_to(new_user_session_url)
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
297
|
+
describe "with invalid params" do
|
298
|
+
it "assigns a newly created but unsaved message as @message" do
|
299
|
+
post :create, :message => @invalid_attrs
|
300
|
+
assigns(:message).should_not be_valid
|
301
|
+
end
|
302
|
+
|
303
|
+
it "should redirect to new_user_session_url" do
|
304
|
+
post :create, :message => @invalid_attrs
|
305
|
+
response.should redirect_to(new_user_session_url)
|
306
|
+
end
|
307
|
+
end
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
describe "PUT update" do
|
312
|
+
before(:each) do
|
313
|
+
@message = messages(:user1_to_user2_1)
|
314
|
+
@attrs = FactoryGirl.attributes_for(:message)
|
315
|
+
@invalid_attrs = {:sender_id => ''}
|
316
|
+
end
|
317
|
+
|
318
|
+
describe "When logged in as Administrator" do
|
319
|
+
login_fixture_admin
|
320
|
+
|
321
|
+
describe "with valid params" do
|
322
|
+
it "updates the requested message" do
|
323
|
+
put :update, :id => @message.id, :message => @attrs
|
324
|
+
end
|
325
|
+
|
326
|
+
it "assigns the requested message as @message" do
|
327
|
+
put :update, :id => @message.id, :message => @attrs
|
328
|
+
assigns(:message).should eq(@message)
|
329
|
+
response.should be_missing
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
333
|
+
describe "with invalid params" do
|
334
|
+
it "assigns the requested message as @message" do
|
335
|
+
put :update, :id => @message.id, :message => @invalid_attrs
|
336
|
+
end
|
337
|
+
|
338
|
+
it "re-renders the 'edit' template" do
|
339
|
+
put :update, :id => @message.id, :message => @invalid_attrs
|
340
|
+
response.should be_missing
|
341
|
+
end
|
342
|
+
end
|
343
|
+
end
|
344
|
+
|
345
|
+
describe "When logged in as Librarian" do
|
346
|
+
login_fixture_librarian
|
347
|
+
|
348
|
+
describe "with valid params" do
|
349
|
+
it "updates the requested message" do
|
350
|
+
put :update, :id => @message.id, :message => @attrs
|
351
|
+
end
|
352
|
+
|
353
|
+
it "assigns the requested message as @message" do
|
354
|
+
put :update, :id => @message.id, :message => @attrs
|
355
|
+
assigns(:message).should eq(@message)
|
356
|
+
response.should be_forbidden
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
360
|
+
describe "with invalid params" do
|
361
|
+
it "assigns the requested message as @message" do
|
362
|
+
put :update, :id => @message.id, :message => @invalid_attrs
|
363
|
+
end
|
364
|
+
|
365
|
+
it "re-renders the 'edit' template" do
|
366
|
+
put :update, :id => @message.id, :message => @invalid_attrs
|
367
|
+
response.should be_forbidden
|
368
|
+
end
|
369
|
+
end
|
370
|
+
end
|
371
|
+
|
372
|
+
describe "When logged in as User" do
|
373
|
+
login_fixture_user
|
374
|
+
|
375
|
+
describe "with valid params" do
|
376
|
+
it "updates the requested message" do
|
377
|
+
put :update, :id => @message.id, :message => @attrs
|
378
|
+
end
|
379
|
+
|
380
|
+
it "assigns the requested message as @message" do
|
381
|
+
put :update, :id => @message.id, :message => @attrs
|
382
|
+
assigns(:message).should eq(@message)
|
383
|
+
response.should be_forbidden
|
384
|
+
end
|
385
|
+
end
|
386
|
+
|
387
|
+
describe "with invalid params" do
|
388
|
+
it "assigns the requested message as @message" do
|
389
|
+
put :update, :id => @message.id, :message => @invalid_attrs
|
390
|
+
end
|
391
|
+
|
392
|
+
it "re-renders the 'edit' template" do
|
393
|
+
put :update, :id => @message.id, :message => @invalid_attrs
|
394
|
+
response.should be_forbidden
|
395
|
+
end
|
396
|
+
end
|
397
|
+
|
398
|
+
it "should not update my message" do
|
399
|
+
put :update, :id => 2, :message => { }
|
400
|
+
response.should be_forbidden
|
401
|
+
end
|
402
|
+
|
403
|
+
it "should not update other user's message" do
|
404
|
+
put :update, :id => 1, :message => { }
|
405
|
+
response.should be_forbidden
|
406
|
+
end
|
407
|
+
end
|
408
|
+
|
409
|
+
describe "When not logged in" do
|
410
|
+
it "assigns the requested message as @message" do
|
411
|
+
put :update, :id => 2, :message => { }
|
412
|
+
response.should redirect_to new_user_session_url
|
413
|
+
end
|
414
|
+
end
|
415
|
+
end
|
416
|
+
|
417
|
+
describe "DELETE destroy" do
|
418
|
+
describe "When logged in as User" do
|
419
|
+
login_fixture_user
|
420
|
+
|
421
|
+
it "should destroy own message" do
|
422
|
+
delete :destroy, :id => 2
|
423
|
+
response.should redirect_to messages_url
|
424
|
+
end
|
425
|
+
|
426
|
+
it "should not destroy other user's message" do
|
427
|
+
delete :destroy, :id => 1
|
428
|
+
response.should be_forbidden
|
429
|
+
end
|
430
|
+
end
|
431
|
+
|
432
|
+
describe "When not logged in" do
|
433
|
+
it "destroys the requested message" do
|
434
|
+
delete :destroy, :id => 1
|
435
|
+
end
|
436
|
+
|
437
|
+
it "should be redirected to new_user_session_url" do
|
438
|
+
delete :destroy, :id => 1
|
439
|
+
response.should redirect_to(new_user_session_url)
|
440
|
+
end
|
441
|
+
end
|
442
|
+
end
|
443
|
+
end
|
data/spec/dummy/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
4
|
+
|
5
|
+
require File.expand_path('../config/application', __FILE__)
|
6
|
+
|
7
|
+
Dummy::Application.load_tasks
|