enju_message 0.3.0.beta.1 → 0.3.3

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.
Files changed (76) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +10 -0
  3. data/app/models/message.rb +5 -5
  4. data/app/models/message_request.rb +3 -4
  5. data/app/models/message_request_transition.rb +3 -4
  6. data/app/models/message_template.rb +3 -3
  7. data/app/models/message_transition.rb +3 -4
  8. data/app/views/message_templates/_form.html.erb +1 -1
  9. data/app/views/messages/index.rss.builder +2 -2
  10. data/db/migrate/149_create_message_templates.rb +3 -8
  11. data/db/migrate/154_create_messages.rb +4 -8
  12. data/db/migrate/20080819181903_create_message_requests.rb +2 -7
  13. data/db/migrate/20110913115320_add_lft_and_rgt_to_message.rb +2 -7
  14. data/db/migrate/20120125050502_add_depth_to_message.rb +1 -2
  15. data/db/migrate/20140518111006_create_message_transitions.rb +3 -8
  16. data/db/migrate/20140518135713_create_message_request_transitions.rb +3 -8
  17. data/db/migrate/20160703185015_add_most_recent_to_message_transitions.rb +1 -1
  18. data/db/migrate/20160814165332_add_most_recent_to_message_request_transitions.rb +1 -1
  19. data/db/migrate/20180107162659_add_constraints_to_most_recent_for_message_transitions.rb +1 -1
  20. data/db/migrate/20180107162711_add_constraints_to_most_recent_for_message_request_transitions.rb +1 -1
  21. data/lib/enju_message/version.rb +1 -1
  22. data/spec/controllers/messages_controller_spec.rb +27 -25
  23. data/spec/dummy/app/controllers/application_controller.rb +0 -1
  24. data/spec/dummy/app/jobs/application_job.rb +7 -0
  25. data/spec/dummy/app/models/application_record.rb +3 -0
  26. data/spec/dummy/app/models/user.rb +1 -1
  27. data/spec/dummy/bin/bundle +1 -1
  28. data/spec/dummy/bin/setup +1 -3
  29. data/spec/dummy/bin/update +4 -2
  30. data/spec/dummy/bin/yarn +3 -3
  31. data/spec/dummy/config/application.rb +1 -1
  32. data/spec/dummy/config/environments/development.rb +9 -2
  33. data/spec/dummy/config/environments/production.rb +7 -4
  34. data/spec/dummy/config/environments/test.rb +5 -1
  35. data/spec/dummy/config/storage.yml +34 -0
  36. data/spec/dummy/db/migrate/005_create_manifestations.rb +3 -3
  37. data/spec/dummy/db/migrate/20100606065209_create_user_has_roles.rb +2 -4
  38. data/spec/dummy/db/migrate/20140122054321_create_profiles.rb +4 -5
  39. data/spec/dummy/db/migrate/20150421023923_create_identities.rb +14 -0
  40. data/spec/dummy/db/migrate/20151126005552_add_provider_to_identity.rb +5 -0
  41. data/spec/dummy/db/migrate/20151213070943_add_translation_table_to_library_group.rb +0 -8
  42. data/spec/dummy/db/migrate/20160319144230_create_issn_records.rb +11 -0
  43. data/spec/dummy/db/migrate/20160506144040_create_isbn_records.rb +11 -0
  44. data/spec/dummy/db/migrate/20170114174536_add_profile_id_to_user.rb +5 -0
  45. data/spec/dummy/db/migrate/20170116134107_create_issn_record_and_manifestations.rb +11 -0
  46. data/spec/dummy/db/migrate/20170116134120_create_isbn_record_and_manifestations.rb +11 -0
  47. data/spec/dummy/db/migrate/20180107160726_add_constraints_to_most_recent_for_user_import_file_transitions.rb +1 -1
  48. data/spec/dummy/db/migrate/20180107160740_add_constraints_to_most_recent_for_user_export_file_transitions.rb +1 -1
  49. data/spec/dummy/db/migrate/20180107161311_add_constraints_to_most_recent_for_agent_import_file_transitions.rb +1 -1
  50. data/spec/dummy/db/migrate/20180107161331_add_constraints_to_most_recent_for_resource_import_file_transitions.rb +1 -1
  51. data/spec/dummy/db/migrate/20180107161347_add_constraints_to_most_recent_for_resource_export_file_transitions.rb +1 -1
  52. data/spec/dummy/db/migrate/20180107161410_add_constraints_to_most_recent_for_import_request_transitions.rb +1 -1
  53. data/spec/dummy/db/migrate/20181026064038_add_login_banner_to_library_group.rb +6 -0
  54. data/spec/dummy/db/migrate/20181030072731_add_not_null_to_position_on_carrier_type.rb +14 -0
  55. data/spec/dummy/db/migrate/20181030074920_add_not_null_to_position_on_library.rb +14 -0
  56. data/spec/dummy/db/migrate/20190208135957_create_active_storage_tables.active_storage.rb +27 -0
  57. data/spec/dummy/db/migrate/20190818075603_add_memo_to_manifestation.rb +5 -0
  58. data/spec/dummy/db/migrate/20190818075628_add_memo_to_item.rb +5 -0
  59. data/spec/dummy/db/migrate/20191219122214_create_custom_properties.rb +12 -0
  60. data/spec/dummy/db/schema.rb +125 -34
  61. data/spec/factories/message.rb +4 -4
  62. data/spec/factories/message_request.rb +1 -1
  63. data/spec/factories/profile.rb +10 -7
  64. data/spec/factories/user.rb +25 -22
  65. data/spec/fixtures/message_request_transitions.yml +2 -2
  66. data/spec/fixtures/message_requests.yml +2 -3
  67. data/spec/fixtures/message_templates.yml +2 -2
  68. data/spec/fixtures/messages.yml +3 -3
  69. data/spec/models/message_request_spec.rb +2 -3
  70. data/spec/models/message_spec.rb +3 -3
  71. data/spec/models/message_template_spec.rb +2 -2
  72. data/spec/views/messages/index.html.erb_spec.rb +3 -9
  73. metadata +99 -28
  74. data/README.rdoc +0 -10
  75. data/spec/dummy/config/initializers/secret_token.rb +0 -7
  76. data/spec/dummy/config/initializers/session_store.rb +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e75af30f09ac93f59585860221a94ba9236b3e2d
4
- data.tar.gz: 9d3eb4ac9e0ea0bf7703e4d7c170747827739ae9
2
+ SHA256:
3
+ metadata.gz: 130ddb20f59265f2d8be22eb8a4bb49a4866ac7e764a9444077b6a92e8d01174
4
+ data.tar.gz: 5a8b99d000b3e04431eef716f279171a72e10e636580edbc9920c733a9d3bac8
5
5
  SHA512:
6
- metadata.gz: 207d25d934a7d825adb0e2ed0c2b0ecc0e9116b934e24523ca6e5b0c27945861b97687a18f846094dbecfc3b7df51da4b16c1c8acc55b13660df874ef7e650cc
7
- data.tar.gz: c7222db7109beb1c3f3cfc6ab2b92f58fd8a9b2c254c0b5dc90483ba299230a9a6dddd85129604328f158a2a5294913a2b8f6392e23da1676f278300651e65d6
6
+ metadata.gz: 4f1f078caab25997a3649ec20d42ad5e319c55acd64bed805dc0c97fae19ad412e11af718eb7a75dfb7982a50caa573cb0520617482aa0c7e0b2dd57ee8651d8
7
+ data.tar.gz: 8e1a1826362b0c657ac8c7fa4e0f18a479e1824ab1125feafe28f96e2882b693fd148bd9550d45efd6d3cae272178aa64d7c18f43c8d4aefe394145b635dba48
@@ -0,0 +1,10 @@
1
+ # EnjuMessage
2
+ [![Travis CI](https://travis-ci.com/next-l/enju_message.svg?branch=1.3)](https://travis-ci.com/next-l/enju_message)
3
+ [![Coverage Status](https://coveralls.io/repos/github/next-l/enju_message/badge.svg?branch=1.3)](https://coveralls.io/github/next-l/enju_message?branch=1.3)
4
+ [![security](https://hakiri.io/github/next-l/enju_message/1.3.svg)](https://hakiri.io/github/next-l/enju_message/1.3)
5
+
6
+ This project rocks and uses MIT-LICENSE.
7
+
8
+ ## 製作者・貢献者 (Authors and contributors)
9
+ * [TANABE, Kosuke](https://github.com/nabeta) ([@nabeta](https://twitter.com/nabeta))
10
+ * [Project Next-L](https://www.next-l.jp) ([@ProjectNextL](https://twitter.com/ProjectNextL))
@@ -1,4 +1,4 @@
1
- class Message < ActiveRecord::Base
1
+ class Message < ApplicationRecord
2
2
  include Statesman::Adapters::ActiveRecordQueries
3
3
  scope :unread, -> {in_state('unread')}
4
4
  belongs_to :message_request, optional: true
@@ -42,7 +42,7 @@ class Message < ActiveRecord::Base
42
42
 
43
43
  def set_receiver
44
44
  if recipient
45
- self.receiver = User.where(username: recipient).first
45
+ self.receiver = User.find_by(username: recipient)
46
46
  end
47
47
  end
48
48
 
@@ -80,14 +80,14 @@ end
80
80
  #
81
81
  # id :integer not null, primary key
82
82
  # read_at :datetime
83
- # receiver_id :integer
84
83
  # sender_id :integer
84
+ # receiver_id :integer
85
85
  # subject :string not null
86
86
  # body :text
87
87
  # message_request_id :integer
88
88
  # parent_id :integer
89
- # created_at :datetime
90
- # updated_at :datetime
89
+ # created_at :datetime not null
90
+ # updated_at :datetime not null
91
91
  # lft :integer
92
92
  # rgt :integer
93
93
  # depth :integer
@@ -1,4 +1,4 @@
1
- class MessageRequest < ActiveRecord::Base
1
+ class MessageRequest < ApplicationRecord
2
2
  include Statesman::Adapters::ActiveRecordQueries
3
3
  scope :not_sent, -> {in_state(:pending).where('sent_at IS NULL')}
4
4
  scope :sent, -> {in_state(:sent)}
@@ -83,8 +83,7 @@ end
83
83
  # receiver_id :integer
84
84
  # message_template_id :integer
85
85
  # sent_at :datetime
86
- # deleted_at :datetime
87
86
  # body :text
88
- # created_at :datetime
89
- # updated_at :datetime
87
+ # created_at :datetime not null
88
+ # updated_at :datetime not null
90
89
  #
@@ -1,6 +1,5 @@
1
- class MessageRequestTransition < ActiveRecord::Base
1
+ class MessageRequestTransition < ApplicationRecord
2
2
  include Statesman::Adapters::ActiveRecordTransition
3
-
4
3
 
5
4
  belongs_to :message_request, inverse_of: :message_request_transitions
6
5
  # attr_accessible :to_state, :sort_key, :metadata
@@ -15,7 +14,7 @@ end
15
14
  # metadata :text default({})
16
15
  # sort_key :integer
17
16
  # message_request_id :integer
18
- # created_at :datetime
19
- # updated_at :datetime
17
+ # created_at :datetime not null
18
+ # updated_at :datetime not null
20
19
  # most_recent :boolean not null
21
20
  #
@@ -1,4 +1,4 @@
1
- class MessageTemplate < ActiveRecord::Base
1
+ class MessageTemplate < ApplicationRecord
2
2
  has_many :message_requests
3
3
 
4
4
  validates :status, uniqueness: true
@@ -31,6 +31,6 @@ end
31
31
  # body :text not null
32
32
  # position :integer
33
33
  # locale :string default("en")
34
- # created_at :datetime
35
- # updated_at :datetime
34
+ # created_at :datetime not null
35
+ # updated_at :datetime not null
36
36
  #
@@ -1,6 +1,5 @@
1
- class MessageTransition < ActiveRecord::Base
1
+ class MessageTransition < ApplicationRecord
2
2
  include Statesman::Adapters::ActiveRecordTransition
3
-
4
3
 
5
4
  belongs_to :message, inverse_of: :message_transitions
6
5
  # attr_accessible :to_state, :sort_key, :metadata
@@ -15,7 +14,7 @@ end
15
14
  # metadata :text default({})
16
15
  # sort_key :integer
17
16
  # message_id :integer
18
- # created_at :datetime
19
- # updated_at :datetime
17
+ # created_at :datetime not null
18
+ # updated_at :datetime not null
20
19
  # most_recent :boolean not null
21
20
  #
@@ -8,7 +8,7 @@
8
8
 
9
9
  <div class="field">
10
10
  <%= f.label :locale %><br />
11
- <%= f.select(:locale, @available_languages.collect{|language| [language.display_name.localize, language.iso_639_1]}) %>
11
+ <%= f.select(:locale, @available_languages.collect{|language| [language.display_name, language.iso_639_1]}) %>
12
12
  </div>
13
13
 
14
14
  <div class="field">
@@ -7,7 +7,7 @@ xml.rss('version' => "2.0",
7
7
  xml.title t('message.user_message', login_name: @user.username)
8
8
  xml.link messages_url(@user, format: :rss)
9
9
  else
10
- xml.title t('message.library_group_message', library_group_name: @library_group.display_name.localize)
10
+ xml.title t('message.library_group_message', library_group_name: @library_group.display_name)
11
11
  xml.link messages_url(format: :rss)
12
12
  end
13
13
  xml.description "Next-L Enju, an open source integrated library system developed by Project Next-L"
@@ -16,7 +16,7 @@ xml.rss('version' => "2.0",
16
16
  xml.tag! "atom:link", rel: 'self', href: messages_url(format: :rss)
17
17
  xml.tag! "atom:link", rel: 'alternate', href: messages_url
18
18
  # xml.tag! "atom:link", rel: 'search', type: 'application/opensearchdescription+xml', href: "http://#{request.host_with_port}/page/opensearch"
19
- unless params[:query].blank?
19
+ if params[:query].present?
20
20
  xml.tag! "opensearch:totalResults", @messages.total_entries
21
21
  xml.tag! "opensearch:startIndex", @messages.offset + 1
22
22
  xml.tag! "opensearch:itemsPerPage", @messages.per_page
@@ -1,7 +1,7 @@
1
- class CreateMessageTemplates < ActiveRecord::Migration[4.2]
2
- def self.up
1
+ class CreateMessageTemplates < ActiveRecord::Migration[5.2]
2
+ def change
3
3
  create_table :message_templates do |t|
4
- t.string :status, null: false
4
+ t.string :status, null: false, index: {unique: true}
5
5
  t.text :title, null: false
6
6
  t.text :body, null: false
7
7
  t.integer :position
@@ -9,10 +9,5 @@ class CreateMessageTemplates < ActiveRecord::Migration[4.2]
9
9
 
10
10
  t.timestamps
11
11
  end
12
- add_index :message_templates, :status, unique: true
13
- end
14
-
15
- def self.down
16
- drop_table :message_templates
17
12
  end
18
13
  end
@@ -1,19 +1,15 @@
1
- class CreateMessages < ActiveRecord::Migration[4.2]
2
- def self.up
3
- create_table :messages, force: true do |t|
1
+ class CreateMessages < ActiveRecord::Migration[5.2]
2
+ def change
3
+ create_table :messages do |t|
4
4
  t.datetime :read_at
5
5
  t.references :sender, index: true
6
6
  t.references :receiver, index: true
7
7
  t.string :subject, null: false
8
8
  t.text :body
9
9
  t.references :message_request, index: true
10
- t.references :parent, index: true
10
+ t.references :parent, foreign_key: {to_table: :messages}
11
11
 
12
12
  t.timestamps
13
13
  end
14
14
  end
15
-
16
- def self.down
17
- drop_table :messages
18
- end
19
15
  end
@@ -1,18 +1,13 @@
1
- class CreateMessageRequests < ActiveRecord::Migration[4.2]
2
- def self.up
1
+ class CreateMessageRequests < ActiveRecord::Migration[5.2]
2
+ def change
3
3
  create_table :message_requests do |t|
4
4
  t.references :sender
5
5
  t.references :receiver
6
6
  t.references :message_template
7
7
  t.datetime :sent_at
8
- t.datetime :deleted_at
9
8
  t.text :body
10
9
 
11
10
  t.timestamps
12
11
  end
13
12
  end
14
-
15
- def self.down
16
- drop_table :message_requests
17
- end
18
13
  end
@@ -1,11 +1,6 @@
1
- class AddLftAndRgtToMessage < ActiveRecord::Migration[4.2]
2
- def self.up
1
+ class AddLftAndRgtToMessage < ActiveRecord::Migration[5.2]
2
+ def change
3
3
  add_column :messages, :lft, :integer
4
4
  add_column :messages, :rgt, :integer
5
5
  end
6
-
7
- def self.down
8
- remove_column :messages, :rgt
9
- remove_column :messages, :lft
10
- end
11
6
  end
@@ -1,6 +1,5 @@
1
- class AddDepthToMessage < ActiveRecord::Migration[4.2]
1
+ class AddDepthToMessage < ActiveRecord::Migration[5.2]
2
2
  def change
3
3
  add_column :messages, :depth, :integer
4
-
5
4
  end
6
5
  end
@@ -1,18 +1,13 @@
1
- class CreateMessageTransitions < ActiveRecord::Migration[4.2]
1
+ class CreateMessageTransitions < ActiveRecord::Migration[5.2]
2
2
  def change
3
3
  create_table :message_transitions do |t|
4
4
  t.string :to_state
5
- if ActiveRecord::Base.configurations[Rails.env]["adapter"].try(:match, /mysql/)
6
- t.text :metadata
7
- else
8
- t.text :metadata, default: "{}"
9
- end
5
+ t.text :metadata, default: '{}'
10
6
  t.integer :sort_key
11
- t.integer :message_id
7
+ t.references :message
12
8
  t.timestamps
13
9
  end
14
10
 
15
- add_index :message_transitions, :message_id
16
11
  add_index :message_transitions, [:sort_key, :message_id], unique: true
17
12
  end
18
13
  end
@@ -1,18 +1,13 @@
1
- class CreateMessageRequestTransitions < ActiveRecord::Migration[4.2]
1
+ class CreateMessageRequestTransitions < ActiveRecord::Migration[5.2]
2
2
  def change
3
3
  create_table :message_request_transitions do |t|
4
4
  t.string :to_state
5
- if ActiveRecord::Base.configurations[Rails.env]["adapter"].try(:match, /mysql/)
6
- t.text :metadata
7
- else
8
- t.text :metadata, default: "{}"
9
- end
5
+ t.text :metadata, default: '{}'
10
6
  t.integer :sort_key
11
- t.integer :message_request_id
7
+ t.references :message_request
12
8
  t.timestamps
13
9
  end
14
10
 
15
- add_index :message_request_transitions, :message_request_id
16
11
  add_index :message_request_transitions, [:sort_key, :message_request_id], unique: true, name: "index_message_request_transitions_on_sort_key_and_request_id"
17
12
  end
18
13
  end
@@ -1,4 +1,4 @@
1
- class AddMostRecentToMessageTransitions < ActiveRecord::Migration[4.2]
1
+ class AddMostRecentToMessageTransitions < ActiveRecord::Migration[5.2]
2
2
  def up
3
3
  add_column :message_transitions, :most_recent, :boolean, null: true
4
4
  end
@@ -1,4 +1,4 @@
1
- class AddMostRecentToMessageRequestTransitions < ActiveRecord::Migration[4.2]
1
+ class AddMostRecentToMessageRequestTransitions < ActiveRecord::Migration[5.2]
2
2
  def up
3
3
  add_column :message_request_transitions, :most_recent, :boolean, null: true
4
4
  end
@@ -1,4 +1,4 @@
1
- class AddConstraintsToMostRecentForMessageTransitions < ActiveRecord::Migration[4.2]
1
+ class AddConstraintsToMostRecentForMessageTransitions < ActiveRecord::Migration[5.2]
2
2
  disable_ddl_transaction!
3
3
 
4
4
  def up
@@ -1,4 +1,4 @@
1
- class AddConstraintsToMostRecentForMessageRequestTransitions < ActiveRecord::Migration[4.2]
1
+ class AddConstraintsToMostRecentForMessageRequestTransitions < ActiveRecord::Migration[5.2]
2
2
  disable_ddl_transaction!
3
3
 
4
4
  def up
@@ -1,3 +1,3 @@
1
1
  module EnjuMessage
2
- VERSION = "0.3.0.beta.1"
2
+ VERSION = "0.3.3".freeze
3
3
  end
@@ -14,7 +14,7 @@ describe MessagesController do
14
14
  it 'should get its own messages' do
15
15
  get :index
16
16
  assigns(:messages).should_not be_nil
17
- response.should be_success
17
+ response.should be_successful
18
18
  end
19
19
 
20
20
  describe 'When user_id is specified' do
@@ -31,7 +31,7 @@ describe MessagesController do
31
31
  it 'should get its own messages' do
32
32
  get :index
33
33
  assigns(:messages).should_not be_nil
34
- response.should be_success
34
+ response.should be_successful
35
35
  end
36
36
 
37
37
  describe 'When user_id is specified' do
@@ -55,13 +55,13 @@ describe MessagesController do
55
55
  it 'should get its own messages' do
56
56
  get :index
57
57
  assigns(:messages).should_not be_nil
58
- response.should be_success
58
+ response.should be_successful
59
59
  end
60
60
 
61
61
  it 'should get index with query' do
62
62
  get :index, params: { query: 'you' }
63
63
  assigns(:messages).first.receiver.should eq users(:user1)
64
- response.should be_success
64
+ response.should be_successful
65
65
  end
66
66
  end
67
67
 
@@ -106,7 +106,7 @@ describe MessagesController do
106
106
 
107
107
  it 'should show my message' do
108
108
  get :show, params: { id: messages(:user2_to_user1_1).id }
109
- response.should be_success
109
+ response.should be_successful
110
110
  end
111
111
 
112
112
  it "should should not show other user's message" do
@@ -141,7 +141,7 @@ describe MessagesController do
141
141
  it 'should not assign the requested message as @message' do
142
142
  get :new
143
143
  assigns(:message).should_not be_valid
144
- response.should be_success
144
+ response.should be_successful
145
145
  end
146
146
  end
147
147
 
@@ -189,7 +189,7 @@ describe MessagesController do
189
189
  get :edit, params: { id: message.id }
190
190
  end.should raise_error(ActiveRecord::RecordNotFound)
191
191
  assigns(:message).should be_nil
192
- response.should be_success
192
+ response.should be_successful
193
193
  end
194
194
  end
195
195
 
@@ -202,7 +202,7 @@ describe MessagesController do
202
202
  get :edit, params: { id: message.id }
203
203
  end.should raise_error(ActiveRecord::RecordNotFound)
204
204
  assigns(:message).should be_nil
205
- response.should be_success
205
+ response.should be_successful
206
206
  end
207
207
  end
208
208
 
@@ -215,7 +215,7 @@ describe MessagesController do
215
215
  get :edit, params: { id: message.id }
216
216
  end.should raise_error(ActiveRecord::RecordNotFound)
217
217
  assigns(:message).should be_nil
218
- response.should be_success
218
+ response.should be_successful
219
219
  end
220
220
  end
221
221
 
@@ -261,18 +261,20 @@ describe MessagesController do
261
261
  it "re-renders the 'new' template" do
262
262
  post :create, params: { message: @invalid_attrs, user_id: users(:user1).username }
263
263
  response.should render_template('new')
264
- response.should be_success
264
+ response.should be_successful
265
265
  end
266
266
  end
267
+
267
268
  describe 'with invalid recipient' do
268
269
  it "re-renders the 'new' template" do
269
270
  post :create, params: { message: @invalid_user_attrs }
270
271
  message = assigns(:message)
271
272
  message.should_not be_valid
272
273
  message.errors.should have_key :receiver
273
- message.errors.added?(:receiver, :invalid).should be_truthy
274
+ message.errors.added?(:receiver, :blank).should be_truthy
274
275
  response.should render_template('new')
275
276
  end
277
+
276
278
  it "re-renders the 'new' template" do
277
279
  post :create, params: { message: @blank_user_attrs }
278
280
  message = assigns(:message)
@@ -371,7 +373,7 @@ describe MessagesController do
371
373
  lambda do
372
374
  put :update, params: { id: @message.id, message: @invalid_attrs }
373
375
  end.should raise_error(ActiveRecord::RecordNotFound)
374
- response.should be_success
376
+ response.should be_successful
375
377
  end
376
378
  end
377
379
  end
@@ -391,7 +393,7 @@ describe MessagesController do
391
393
  put :update, params: { id: @message.id, message: @attrs }
392
394
  end.should raise_error(ActiveRecord::RecordNotFound)
393
395
  assigns(:message).should be_nil
394
- response.should be_success
396
+ response.should be_successful
395
397
  end
396
398
  end
397
399
 
@@ -406,7 +408,7 @@ describe MessagesController do
406
408
  lambda do
407
409
  put :update, params: { id: @message.id, message: @invalid_attrs }
408
410
  end.should raise_error(ActiveRecord::RecordNotFound)
409
- response.should be_success
411
+ response.should be_successful
410
412
  end
411
413
  end
412
414
  end
@@ -426,7 +428,7 @@ describe MessagesController do
426
428
  put :update, params: { id: @message.id, message: @attrs }
427
429
  end.should raise_error(ActiveRecord::RecordNotFound)
428
430
  assigns(:message).should be_nil
429
- response.should be_success
431
+ response.should be_successful
430
432
  end
431
433
  end
432
434
 
@@ -441,26 +443,26 @@ describe MessagesController do
441
443
  lambda do
442
444
  put :update, params: { id: @message.id, message: @invalid_attrs }
443
445
  end.should raise_error(ActiveRecord::RecordNotFound)
444
- response.should be_success
446
+ response.should be_successful
445
447
  end
446
448
  end
447
449
 
448
450
  it 'should not update my message' do
449
- put :update, params: { id: 2, message: {} }
451
+ put :update, params: { id: messages(:user2_to_user1_1), message: {} }
450
452
  response.should be_forbidden
451
453
  end
452
454
 
453
455
  it "should not update other user's message" do
454
456
  lambda do
455
- put :update, params: { id: 1, message: {} }
457
+ put :update, params: { id: messages(:user1_to_user2_1), message: {} }
456
458
  end.should raise_error(ActiveRecord::RecordNotFound)
457
- response.should be_success
459
+ response.should be_successful
458
460
  end
459
461
  end
460
462
 
461
463
  describe 'When not logged in' do
462
464
  it 'assigns the requested message as @message' do
463
- put :update, params: { id: 2, message: {} }
465
+ put :update, params: { id: messages(:user2_to_user1_1), message: {} }
464
466
  response.should redirect_to new_user_session_url
465
467
  end
466
468
  end
@@ -480,27 +482,27 @@ describe MessagesController do
480
482
  login_fixture_user
481
483
 
482
484
  it 'should destroy own message' do
483
- delete :destroy, params: { id: 2 }
485
+ delete :destroy, params: { id: messages(:user2_to_user1_1) }
484
486
  response.should redirect_to messages_url
485
487
  response.should_not be_forbidden
486
488
  end
487
489
 
488
490
  it "should not destroy other user's message" do
489
491
  lambda do
490
- delete :destroy, params: { id: 1 }
492
+ delete :destroy, params: { id: messages(:user1_to_user2_1) }
491
493
  end.should raise_error(ActiveRecord::RecordNotFound)
492
- response.should be_success
494
+ response.should be_successful
493
495
  end
494
496
  end
495
497
 
496
498
  describe 'When not logged in' do
497
499
  it 'destroys the requested message' do
498
- delete :destroy, params: { id: 1 }
500
+ delete :destroy, params: { id: messages(:user1_to_user2_1) }
499
501
  response.should redirect_to(new_user_session_url)
500
502
  end
501
503
 
502
504
  it 'should be redirected to new_user_session_url' do
503
- delete :destroy, params: { id: 1 }
505
+ delete :destroy, params: { id: messages(:user1_to_user2_1) }
504
506
  response.should redirect_to(new_user_session_url)
505
507
  end
506
508
  end