nay-record_with_operator 0.0.10 → 0.0.11

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.
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ DESCRIPTION = "Rails plugin to set created_by, updated_by, deleted_by to ActiveR
12
12
  GITHUB_PROJECT = "record_with_operator"
13
13
  HOMEPAGE = "http://github.com/nay/#{GITHUB_PROJECT}/tree"
14
14
  BIN_FILES = %w( )
15
- VER = "0.0.10"
15
+ VER = "0.0.11"
16
16
  CLEAN.include ['pkg']
17
17
 
18
18
  desc 'Default: run unit tests.'
@@ -5,7 +5,7 @@ module AssociationWithOperator
5
5
  if results.kind_of? Array
6
6
  results.each{|r| r.operator = proxy_owner.operator}
7
7
  else
8
- results.operator = proxy_owner.operator
8
+ results.operator = proxy_owner.operator if results
9
9
  end
10
10
  results
11
11
  end
@@ -205,17 +205,47 @@ class RecordWithOperatorTest < ActiveSupport::TestCase
205
205
  assert note.memos.find_all_by_body("memo").all?{|m| m.operator == @user2}
206
206
  end
207
207
 
208
-
209
208
  def test_found_memo_through_named_scope_should_have_operator
210
209
  note = NoteWithUser.find(@note_created_by_user1.id, :for => @user2)
211
210
  note.memos.create!(:body => "memo")
212
211
  assert_equal @user2, note.memos.new_arrivals.first.operator
213
212
  end
214
213
 
215
-
216
214
  def test_dynamically_found_memo_through_named_scope_should_have_operator
217
215
  note = NoteWithUser.find(@note_created_by_user1.id, :for => @user2)
218
216
  note.memos.create!(:body => "memo")
219
217
  assert_equal @user2, note.memos.new_arrivals.find_by_body("memo").operator
220
218
  end
219
+
220
+ def test_auto_found_memo_first_should_be_nil_if_note_has_no_memo
221
+ note = NoteWithUser.find(@note_created_by_user1.id, :for => @user2)
222
+ assert_equal nil, note.memos.first
223
+ assert_equal nil, note.memos(true).first
224
+ end
225
+
226
+ def test_auto_found_memo_last_should_be_nil_if_note_has_no_memo
227
+ note = NoteWithUser.find(@note_created_by_user1.id, :for => @user2)
228
+ assert_equal nil, note.memos.last
229
+ assert_equal nil, note.memos(true).last
230
+ end
231
+
232
+ def test_manualy_found_memo_first_should_be_nil_if_note_has_no_memo
233
+ note = NoteWithUser.find(@note_created_by_user1.id, :for => @user2)
234
+ assert_equal nil, note.memos.find(:first)
235
+ end
236
+
237
+ def test_manualy_found_memo_last_should_be_nil_if_note_has_no_memo
238
+ note = NoteWithUser.find(@note_created_by_user1.id, :for => @user2)
239
+ assert_equal nil, note.memos.find(:last)
240
+ end
241
+
242
+ def test_dynamically_found_memos_first_should_be_nil_if_note_has_no_memo
243
+ note = NoteWithUser.find(@note_created_by_user1.id, :for => @user2)
244
+ assert_equal nil, note.memos.find_all_by_body("memo").first
245
+ end
246
+
247
+ def test_found_memo_through_named_scope_last_should_be_nil_if_note_has_no_memo
248
+ note = NoteWithUser.find(@note_created_by_user1.id, :for => @user2)
249
+ assert_equal nil, note.memos.new_arrivals.last
250
+ end
221
251
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nay-record_with_operator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yasuko Ohba