acts-as-messageable 0.4.10 → 0.4.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,9 +5,7 @@ module ActsAsMessageable
5
5
  end
6
6
 
7
7
  def attr_accessible(*args)
8
- if defined?(ProtectedAttributes)
9
- @subject.attr_accessible(*args)
10
- end
8
+ @subject.attr_accessible(*args) if defined?(ProtectedAttributes)
11
9
  end
12
10
 
13
11
  def default_scope(order_by)
@@ -1,5 +1,4 @@
1
1
  require 'active_record/railtie'
2
- require 'active_support/core_ext'
3
2
 
4
3
  module ActsAsMessageable
5
4
  class Railtie < Rails::Railtie
@@ -2,16 +2,16 @@ module ActsAsMessageable
2
2
  module Relation
3
3
  attr_accessor :relation_context
4
4
 
5
- def process(context = self.relation_context, &block)
6
- self.each do |message|
7
- block.call(message) if block_given?
5
+ def process(context = relation_context)
6
+ each do |message|
7
+ yield(message) if block_given?
8
8
  context.delete_message(message) if message.removed
9
9
  context.restore_message(message) if message.restored
10
10
  end
11
11
  end
12
12
 
13
13
  def conversations
14
- map { |r| r.root.subtree.order("id desc").first }.uniq
14
+ map { |r| r.root.subtree.order('id desc').first }.uniq
15
15
  end
16
16
  end
17
17
  end
@@ -10,27 +10,28 @@ module ActsAsMessageable
10
10
 
11
11
  module ClassMethods
12
12
  def initialize_scopes
13
- scope :are_from, lambda { |*args| where(:sent_messageable_id => args.first, :sent_messageable_type => args.first.class.name) }
14
- scope :are_to, lambda { |*args| where(:received_messageable_id => args.first, :received_messageable_type => args.first.class.name) }
15
- scope :search, lambda { |*args| where("body like :search_txt or topic like :search_txt",:search_txt => "%#{args.first}%")}
16
- scope :connected_with, lambda { |*args| where("(sent_messageable_type = :sent_type and
17
- sent_messageable_id = :sent_id and
18
- sender_delete = :s_delete and sender_permanent_delete = :s_perm_delete) or
19
- (received_messageable_type = :received_type and
20
- received_messageable_id = :received_id and
21
- recipient_delete = :r_delete and recipient_permanent_delete = :r_perm_delete)",
22
- :sent_type => args.first.class.resolve_active_record_ancestor.to_s,
23
- :sent_id => args.first.id,
24
- :received_type => args.first.class.resolve_active_record_ancestor.to_s,
25
- :received_id => args.first.id,
26
- :r_delete => args.last,
27
- :s_delete => args.last,
28
- :r_perm_delete => false,
29
- :s_perm_delete => false)
13
+ scope :are_from, ->(*args) { where(sent_messageable_id: args.first, sent_messageable_type: args.first.class.name) }
14
+ scope :are_to, ->(*args) { where(received_messageable_id: args.first, received_messageable_type: args.first.class.name) }
15
+ scope :search, ->(*args) { where('body like :search_txt or topic like :search_txt', search_txt: "%#{args.first}%") }
16
+ scope :connected_with, lambda { |*args|
17
+ where("(sent_messageable_type = :sent_type and
18
+ sent_messageable_id = :sent_id and
19
+ sender_delete = :s_delete and sender_permanent_delete = :s_perm_delete) or
20
+ (received_messageable_type = :received_type and
21
+ received_messageable_id = :received_id and
22
+ recipient_delete = :r_delete and recipient_permanent_delete = :r_perm_delete)",
23
+ sent_type: args.first.class.resolve_active_record_ancestor.to_s,
24
+ sent_id: args.first.id,
25
+ received_type: args.first.class.resolve_active_record_ancestor.to_s,
26
+ received_id: args.first.id,
27
+ r_delete: args.last,
28
+ s_delete: args.last,
29
+ r_perm_delete: false,
30
+ s_perm_delete: false)
30
31
  }
31
- scope :readed, lambda { where(:opened => true) }
32
- scope :unreaded, lambda { where(:opened => false) }
33
- scope :deleted, lambda { where(:recipient_delete => true, :sender_delete => true) }
32
+ scope :readed, -> { where(opened: true) }
33
+ scope :unreaded, -> { where(opened: false) }
34
+ scope :deleted, -> { where(recipient_delete: true, sender_delete: true) }
34
35
  end
35
36
  end
36
37
  end
@@ -5,18 +5,26 @@ module ActsAsMessageable
5
5
  class MigrationGenerator < Rails::Generators::Base
6
6
  include Rails::Generators::Migration
7
7
 
8
- namespace "acts-as-messageable:migration"
8
+ namespace 'acts-as-messageable:migration'
9
9
 
10
10
  source_root File.join(File.dirname(__FILE__), 'templates')
11
- argument :table_name, :type => :string, :default => "messages"
11
+ argument :table_name, type: :string, default: 'messages'
12
12
 
13
13
  def self.next_migration_number(dirname)
14
14
  ActiveRecord::Generators::Base.next_migration_number(dirname)
15
15
  end
16
16
 
17
17
  def create_migration_file
18
- migration_template 'migration.rb', 'db/migrate/create_messages_table.rb' rescue nil
19
- migration_template 'migration_permanent.rb', 'db/migrate/add_recipient_permanent_delete_and_sender_permanent_delete_to_messages.rb' rescue nil
18
+ begin
19
+ migration_template 'migration.rb', 'db/migrate/create_messages_table.rb'
20
+ rescue StandardError
21
+ nil
22
+ end
23
+ begin
24
+ migration_template 'migration_permanent.rb', 'db/migrate/add_recipient_permanent_delete_and_sender_permanent_delete_to_messages.rb'
25
+ rescue StandardError
26
+ nil
27
+ end
20
28
  end
21
29
  end
22
30
  end
@@ -1,293 +1,288 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "ActsAsMessageable" do
3
+ describe 'ActsAsMessageable' do
4
4
  before do
5
5
  User.acts_as_messageable
6
6
  @message = send_message
7
7
  end
8
8
 
9
- describe "send messages" do
10
- it "alice should have one message" do
11
- @alice.messages.count.should == 1
9
+ describe 'send messages' do
10
+ it 'alice should have one message' do
11
+ expect(@alice.messages.count).to eq(1)
12
12
  end
13
13
 
14
- it "alice should have one message from bob" do
15
- @alice.messages.are_from(@bob).count.should == 1
14
+ it 'alice should have one message from bob' do
15
+ expect(@alice.messages.are_from(@bob).count).to eq(1)
16
16
  end
17
17
 
18
- it "bob should have one message" do
19
- @bob.messages.count.should == 1
18
+ it 'bob should have one message' do
19
+ expect(@bob.messages.count).to eq(1)
20
20
  end
21
21
 
22
- it "bob should have one message to alice in outbox" do
23
- @bob.sent_messages.are_to(@alice).count.should == 1
22
+ it 'bob should have one message to alice in outbox' do
23
+ expect(@bob.sent_messages.are_to(@alice).count).to eq(1)
24
24
  end
25
25
 
26
- it "bob should have one open message from alice" do
27
- @alice.messages.are_from(@bob).process { |m| m.open }
28
- @alice.messages.readed.count.should == 1
26
+ it 'bob should have one open message from alice' do
27
+ @alice.messages.are_from(@bob).process(&:open)
28
+ expect(@alice.messages.readed.count).to eq(1)
29
29
  end
30
30
  end
31
31
 
32
- describe "send messages with bang" do
33
- it "should raise exception" do
34
- expect {
35
- @alice.send_message!(@bob, :body => "body")
36
- }.to raise_error(ActiveRecord::RecordInvalid)
32
+ describe 'send messages with bang' do
33
+ it 'should raise exception' do
34
+ expect do
35
+ @alice.send_message!(@bob, body: 'body')
36
+ end.to raise_error(ActiveRecord::RecordInvalid)
37
37
  end
38
38
 
39
- it "should return message object" do
40
- @alice.send_message!(@bob, :body => "body", :topic => "topic").should
41
- be_kind_of ActsAsMessageable::Message
39
+ it 'should return message object' do
40
+ expect(@alice.send_message!(@bob, body: 'body', topic: 'topic')).to be_kind_of(ActsAsMessageable::Message)
42
41
  end
43
42
  end
44
43
 
45
- describe "inheritance models" do
46
- it "men send message to alice" do
44
+ describe 'inheritance models' do
45
+ it 'men send message to alice' do
47
46
  send_message(@men, @alice)
48
- @men.sent_messages.size.should be_equal(1)
49
- @alice.received_messages.size.should be_equal(2)
47
+ expect(@men.sent_messages.size).to be_equal(1)
48
+ expect(@alice.received_messages.size).to be_equal(2)
50
49
  end
51
50
 
52
- it "messages method should receive all messages connected with user" do
51
+ it 'messages method should receive all messages connected with user' do
53
52
  send_message(@men, @alice)
54
- @men.messages.size.should be_equal(1)
53
+ expect(@men.messages.size).to be_equal(1)
55
54
  end
56
55
 
57
- it "men send message and receive from alice" do
56
+ it 'men send message and receive from alice' do
58
57
  send_message(@men, @alice)
59
58
  send_message(@alice, @men)
60
59
 
61
- @men.messages.size.should be_equal(2)
62
- @men.sent_messages.size.should be_equal(1)
63
- @men.received_messages.size.should be_equal(1)
60
+ expect(@men.messages.size).to be_equal(2)
61
+ expect(@men.sent_messages.size).to be_equal(1)
62
+ expect(@men.received_messages.size).to be_equal(1)
64
63
  end
65
64
  end
66
65
 
67
- describe "reply to messages" do
68
-
69
- it "pat should not be able to reply to a message from bob to alice" do
70
- @reply_message = @pat.reply_to(@message, "Re: Topic", "Body")
71
- @reply_message.should be_nil
66
+ describe 'reply to messages' do
67
+ it 'pat should not be able to reply to a message from bob to alice' do
68
+ @reply_message = @pat.reply_to(@message, 'Re: Topic', 'Body')
69
+ expect(@reply_message).to be_nil
72
70
  end
73
71
 
74
- it "alice should be able to reply to a message from bob to alice" do
75
- @reply_message = @alice.reply_to(@message, "Re: Topic", "Body")
76
- @reply_message.should_not be_nil
77
- @bob.messages.are_from(@alice).count.should == 1
78
- @alice.sent_messages.are_to(@bob).count.should == 1
72
+ it 'alice should be able to reply to a message from bob to alice' do
73
+ @reply_message = @alice.reply_to(@message, 'Re: Topic', 'Body')
74
+ expect(@reply_message).not_to be_nil
75
+ expect(@bob.messages.are_from(@alice).count).to eq(1)
76
+ expect(@alice.sent_messages.are_to(@bob).count).to eq(1)
79
77
  end
80
78
 
81
- it "alice should be able to reply to a message using the message object" do
82
- @reply_message = @message.reply("Re: Topic", "Body")
83
- @reply_message.should_not be_nil
84
- @bob.messages.are_from(@alice).count.should == 1
85
- @alice.sent_messages.are_to(@bob).count.should == 1
79
+ it 'alice should be able to reply to a message using the message object' do
80
+ @reply_message = @message.reply('Re: Topic', 'Body')
81
+ expect(@reply_message).not_to be_nil
82
+ expect(@bob.messages.are_from(@alice).count).to eq(1)
83
+ expect(@alice.sent_messages.are_to(@bob).count).to eq(1)
86
84
  end
87
85
 
88
- it "bob try to add something to conversation" do
89
- @reply_message = @bob.reply_to(@message, "Oh, I Forget", "1+1=2")
90
- @reply_message.from.should == @message.from
91
- @reply_message.to.should == @message.to
86
+ it 'bob try to add something to conversation' do
87
+ @reply_message = @bob.reply_to(@message, 'Oh, I Forget', '1+1=2')
88
+ expect(@reply_message.from).to eq(@message.from)
89
+ expect(@reply_message.to).to eq(@message.to)
92
90
  end
93
91
 
94
- it "bob try to add something to conversation and should receive proper order" do
95
- @reply_message = @bob.reply_to(@message, "Oh, I Forget", "1+1=2")
96
- @sec_message = @alice.reply_to(@message, "Yeah, right", "1+1=3!")
92
+ it 'bob try to add something to conversation and should receive proper order' do
93
+ @reply_message = @bob.reply_to(@message, 'Oh, I Forget', '1+1=2')
94
+ @sec_message = @alice.reply_to(@message, 'Yeah, right', '1+1=3!')
97
95
 
98
- @message.conversation.should == [@sec_message, @reply_message, @message]
96
+ expect(@message.conversation).to eq([@sec_message, @reply_message, @message])
99
97
  end
100
98
  end
101
99
 
102
- describe "delete messages" do
103
-
104
- it "bob should have one deleted message from alice" do
105
- @bob.messages.process do |m|
106
- m.delete
107
- end
100
+ describe 'delete messages' do
101
+ it 'bob should have one deleted message from alice' do
102
+ @bob.messages.process(&:delete)
108
103
 
109
104
  @bob.messages.each do |m|
110
- m.recipient_delete.should == true
111
- m.sender_delete.should == false
105
+ expect(m.recipient_delete).to eq(true)
106
+ expect(m.sender_delete).to eq(false)
112
107
  end
113
108
 
114
- @bob.deleted_messages.count.should == 1
115
- @bob.messages.count.should == 0
109
+ expect(@bob.deleted_messages.count).to eq(1)
110
+ expect(@bob.messages.count).to eq(0)
116
111
  end
117
112
 
118
- it "received_messages and sent_messages should work with .process method" do
119
- @bob.sent_messages.count.should == 1
120
- @alice.received_messages.count.should == 1
113
+ it 'received_messages and sent_messages should work with .process method' do
114
+ expect(@bob.sent_messages.count).to eq(1)
115
+ expect(@alice.received_messages.count).to eq(1)
121
116
 
122
- @bob.sent_messages.process { |m| m.delete }
123
- @bob.sent_messages.count.should == 0
124
- @alice.received_messages.count.should == 1
117
+ @bob.sent_messages.process(&:delete)
118
+ expect(@bob.sent_messages.count).to eq(0)
119
+ expect(@alice.received_messages.count).to eq(1)
125
120
 
126
- @alice.received_messages.process { |m| m.delete }
127
- @alice.received_messages.count.should == 0
121
+ @alice.received_messages.process(&:delete)
122
+ expect(@alice.received_messages.count).to eq(0)
128
123
  end
129
124
 
130
- it "message should permanent delete" do
131
- @alice.messages.process { |m| m.delete }
132
- @alice.messages.count.should == 0
125
+ it 'message should permanent delete' do
126
+ @alice.messages.process(&:delete)
127
+ expect(@alice.messages.count).to eq(0)
133
128
 
134
- @alice.deleted_messages.count.should == 1
135
- @alice.deleted_messages.process { |m| m.delete }
136
- @alice.deleted_messages.count.should == 0
129
+ expect(@alice.deleted_messages.count).to eq(1)
130
+ @alice.deleted_messages.process(&:delete)
131
+ expect(@alice.deleted_messages.count).to eq(0)
137
132
 
138
133
  @message.reload
139
- @message.recipient_permanent_delete.should == true
134
+ expect(@message.recipient_permanent_delete).to eq(true)
140
135
 
141
- @bob.sent_messages.count.should == 1
136
+ expect(@bob.sent_messages.count).to eq(1)
142
137
  end
143
138
 
144
- it "pat should not able to delete message" do
145
- lambda { @pat.delete_message(@message) }.should raise_error
139
+ it 'pat should not able to delete message' do
140
+ expect { @pat.delete_message(@message) }.to raise_error(RuntimeError)
146
141
  end
147
142
  end
148
143
 
149
- describe "restore message" do
150
- it "alice should restore message" do
151
- @alice.received_messages.process { |m| m.delete }
144
+ describe 'restore message' do
145
+ it 'alice should restore message' do
146
+ @alice.received_messages.process(&:delete)
152
147
  @alice.restore_message(@message.reload)
153
- @alice.received_messages.count.should == 1
148
+ expect(@alice.received_messages.count).to eq(1)
154
149
  end
155
150
 
156
- it "should works with relation" do
157
- @alice.received_messages.process { |m| m.delete }
158
- @alice.received_messages.count.should == 0
159
- @alice.deleted_messages.process { |m| m.restore }
160
- @alice.received_messages.count.should == 1
151
+ it 'should works with relation' do
152
+ @alice.received_messages.process(&:delete)
153
+ expect(@alice.received_messages.count).to eq(0)
154
+ @alice.deleted_messages.process(&:restore)
155
+ expect(@alice.received_messages.count).to eq(1)
161
156
  end
162
157
 
163
- it "pat should not able to restore message" do
164
- lambda { @pat.restore_message(@message) }.should raise_error
158
+ it 'pat should not able to restore message' do
159
+ expect { @pat.restore_message(@message) }.to raise_error(RuntimeError)
165
160
  end
166
161
  end
167
162
 
168
- describe "read/unread feature" do
169
- it "alice should have one unread message from bob" do
170
- @alice.messages.are_from(@bob).unreaded.count.should == 1
171
- @alice.messages.are_from(@bob).readed.count.should == 0
163
+ describe 'read/unread feature' do
164
+ it 'alice should have one unread message from bob' do
165
+ expect(@alice.messages.are_from(@bob).unreaded.count).to eq(1)
166
+ expect(@alice.messages.are_from(@bob).readed.count).to eq(0)
172
167
  end
173
168
 
174
- it "alice should able to read message from bob" do
169
+ it 'alice should able to read message from bob' do
175
170
  @alice.messages.are_from(@bob).first.read
176
- @alice.messages.are_from(@bob).unreaded.count.should == 0
171
+ expect(@alice.messages.are_from(@bob).unreaded.count).to eq(0)
177
172
  end
178
173
 
179
- it "alice should able to unread message from bob" do
174
+ it 'alice should able to unread message from bob' do
180
175
  @alice.messages.are_from(@bob).first.read
181
176
  @alice.messages.are_from(@bob).first.unread
182
- @alice.messages.are_from(@bob).unreaded.count.should == 1
177
+ expect(@alice.messages.are_from(@bob).unreaded.count).to eq(1)
183
178
  end
184
179
 
185
- it "alice should able to get datetime when he read bob message" do
180
+ it 'alice should able to get datetime when he read bob message' do
186
181
  @alice.messages.are_from(@bob).first.read
187
182
  read_datetime = @alice.messages.are_from(@bob).first.updated_at
188
- @alice.messages.are_from(@bob).reorder("updated_at asc").first.updated_at.should == read_datetime
183
+ expect(@alice.messages.are_from(@bob).reorder('updated_at asc').first.updated_at).to eq(read_datetime)
189
184
  end
190
185
  end
191
186
 
192
- it "finds proper message" do
187
+ it 'finds proper message' do
193
188
  @bob.messages.find(@message.id) == @message
194
189
  end
195
190
 
196
- it "message should have proper topic" do
197
- @bob.messages.count.should == 1
198
- @bob.messages.first.topic == "Topic"
191
+ it 'message should have proper topic' do
192
+ expect(@bob.messages.count).to eq(1)
193
+ @bob.messages.first.topic == 'Topic'
199
194
  end
200
195
 
201
- describe "conversation" do
202
- it "bob send message to alice, and alice reply to bob message and show proper tree" do
203
- @reply_message = @alice.reply_to(@message, "Re: Topic", "Body")
196
+ describe 'conversation' do
197
+ it 'bob send message to alice, and alice reply to bob message and show proper tree' do
198
+ @reply_message = @alice.reply_to(@message, 'Re: Topic', 'Body')
204
199
 
205
- @reply_message.conversation.size.should == 2
206
- @reply_message.conversation.last.topic.should == "Topic"
207
- @reply_message.conversation.first.topic.should == "Re: Topic"
200
+ expect(@reply_message.conversation.size).to eq(2)
201
+ expect(@reply_message.conversation.last.topic).to eq('Topic')
202
+ expect(@reply_message.conversation.first.topic).to eq('Re: Topic')
208
203
  end
209
204
 
210
- it "bob send message to alice, alice answer, and bob answer for alice answer" do
211
- @reply_message = @alice.reply_to(@message, "Re: Topic", "Body")
212
- @reply_reply_message = @bob.reply_to(@reply_message, "Re: Re: Topic", "Body")
205
+ it 'bob send message to alice, alice answer, and bob answer for alice answer' do
206
+ @reply_message = @alice.reply_to(@message, 'Re: Topic', 'Body')
207
+ @reply_reply_message = @bob.reply_to(@reply_message, 'Re: Re: Topic', 'Body')
213
208
 
214
209
  [@message, @reply_message, @reply_reply_message].each do |m|
215
- m.conversation.size.should == 3
210
+ expect(m.conversation.size).to eq(3)
216
211
  end
217
212
 
218
- @message.conversation.first.should == @reply_reply_message
219
- @reply_reply_message.conversation.first.should == @reply_reply_message
213
+ expect(@message.conversation.first).to eq(@reply_reply_message)
214
+ expect(@reply_reply_message.conversation.first).to eq(@reply_reply_message)
220
215
  end
221
216
  end
222
217
 
223
- describe "conversations" do
218
+ describe 'conversations' do
224
219
  before do
225
- @reply_message = @message.reply("Re: Topic", "Body")
226
- @reply_reply_message = @reply_message.reply("Re: Re: Topic", "Body")
220
+ @reply_message = @message.reply('Re: Topic', 'Body')
221
+ @reply_reply_message = @reply_message.reply('Re: Re: Topic', 'Body')
227
222
  end
228
223
 
229
- it "bob send message to alice and alice reply" do
230
- @bob.messages.conversations.should == [@reply_reply_message]
231
- @reply_message.conversation.should == [@reply_reply_message, @reply_message, @message]
224
+ it 'bob send message to alice and alice reply' do
225
+ expect(@bob.messages.conversations).to eq([@reply_reply_message])
226
+ expect(@reply_message.conversation).to eq([@reply_reply_message, @reply_message, @message])
232
227
  end
233
228
 
234
- it "show conversations in proper order" do
235
- @sec_message = @bob.send_message(@alice, "Hi", "Alice!")
236
- @sec_reply = @sec_message.reply("Re: Hi", "Fine!")
237
- @bob.received_messages.conversations.map(&:id).should == [@sec_reply.id, @reply_reply_message.id]
238
- @sec_reply.conversation.to_a.should == [@sec_reply, @sec_message]
229
+ it 'show conversations in proper order' do
230
+ @sec_message = @bob.send_message(@alice, 'Hi', 'Alice!')
231
+ @sec_reply = @sec_message.reply('Re: Hi', 'Fine!')
232
+ expect(@bob.received_messages.conversations.map(&:id)).to eq([@sec_reply.id, @reply_reply_message.id])
233
+ expect(@sec_reply.conversation.to_a).to eq([@sec_reply, @sec_message])
239
234
  end
240
235
  end
241
236
 
242
- describe "search text from messages" do
237
+ describe 'search text from messages' do
243
238
  before do
244
- @reply_message = @message.reply("Re: Topic", "Body : I am fine")
245
- @reply_reply_message = @reply_message.reply("Re: Re: Topic", "Fine too")
239
+ @reply_message = @message.reply('Re: Topic', 'Body : I am fine')
240
+ @reply_reply_message = @reply_message.reply('Re: Re: Topic', 'Fine too')
246
241
  end
247
242
 
248
- it "bob should be able to search text from messages" do
249
- recordset = @bob.messages.search("I am fine")
250
- recordset.count.should == 1
251
- recordset.should_not be_nil
243
+ it 'bob should be able to search text from messages' do
244
+ recordset = @bob.messages.search('I am fine')
245
+ expect(recordset.count).to eq(1)
246
+ expect(recordset).not_to be_nil
252
247
  end
253
248
  end
254
249
 
255
- describe "send messages with hash" do
256
- it "send message with hash" do
257
- @message = @bob.send_message(@alice, {:body => "Body", :topic => "Topic"})
258
- @message.topic.should == "Topic"
259
- @message.body.should == "Body"
250
+ describe 'send messages with hash' do
251
+ it 'send message with hash' do
252
+ @message = @bob.send_message(@alice, body: 'Body', topic: 'Topic')
253
+ expect(@message.topic).to eq('Topic')
254
+ expect(@message.body).to eq('Body')
260
255
  end
261
256
  end
262
257
 
263
- it "messages should return in right order :created_at" do
264
- @message = send_message(@bob, @alice, "Example", "Example Body")
265
- @alice.messages.last.body.should == "Body"
258
+ it 'messages should return in right order :created_at' do
259
+ @message = send_message(@bob, @alice, 'Example', 'Example Body')
260
+ expect(@alice.messages.last.body).to eq('Body')
266
261
  end
267
262
 
268
- it "received_messages should return unloaded messages" do
269
- @alice.received_messages.loaded?.should be_false
263
+ it 'received_messages should return unloaded messages' do
264
+ expect(@alice.received_messages.loaded?).to be_falsey
270
265
  end
271
266
 
272
- it "sent_messages should return unloaded messages" do
273
- @bob.sent_messages.loaded?.should be_false
267
+ it 'sent_messages should return unloaded messages' do
268
+ expect(@bob.sent_messages.loaded?).to be_falsey
274
269
  end
275
270
 
276
- describe "send messages between two different models (the same id)" do
277
- it "should have the same id" do
278
- @alice.id.should be_equal(@admin.id)
271
+ describe 'send messages between two different models (the same id)' do
272
+ it 'should have the same id' do
273
+ expect(@alice.id).to be_equal(@admin.id)
279
274
  end
280
275
 
281
- it "bob send message to admin (different model) with the same id" do
282
- @bob.send_message(@alice, "hello", "alice")
283
- @alice.messages.are_to(@alice).size.should be_equal(2)
284
- @alice.messages.are_to(@admin).size.should be_equal(0)
276
+ it 'bob send message to admin (different model) with the same id' do
277
+ @bob.send_message(@alice, 'hello', 'alice')
278
+ expect(@alice.messages.are_to(@alice).size).to be_equal(2)
279
+ expect(@alice.messages.are_to(@admin).size).to be_equal(0)
285
280
  end
286
281
 
287
- it "admin send message to bob" do
288
- @admin.send_message(@bob, "hello", "bob")
289
- @bob.messages.are_from(@admin).size.should be_equal(1)
290
- @bob.messages.are_from(@alice).size.should be_equal(0)
282
+ it 'admin send message to bob' do
283
+ @admin.send_message(@bob, 'hello', 'bob')
284
+ expect(@bob.messages.are_from(@admin).size).to be_equal(1)
285
+ expect(@bob.messages.are_from(@alice).size).to be_equal(0)
291
286
  end
292
287
  end
293
288
  end