Skip to content

Commit

Permalink
commentable_type_eq が機能しているかどうかを検証するテストを追加
Browse files Browse the repository at this point in the history
refs #1510
refs #1521 (comment)

### 概要
commentable_type_eq での絞込が機能しているかどうかを検証するテストを追加した

### 修正内容
#### commentable_type_eq が機能しているかどうかを検証するテストを追加
コメントを検索する際は条件として commentable_type_eq を設定するが、 既存ではそれが機能しているかを検証するテストがなかった
そのため、下記の2件のテストを追加し commentable_type_eq が機能しているかを検証した

- :all 以外の document_type を指定して検索した結果が、指定した document_type のコメントのみであるかの検証
- document_type に何も指定せずに検索した結果に、全ての document_type が含まれているかの検証

refs #1521 (comment)
  • Loading branch information
sanfrecce-osaka committed Apr 27, 2020
1 parent ab70a01 commit 28d8c80
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/models/searcher_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,20 @@ class SearchableTest < ActiveSupport::TestCase
assert_includes(result, comments(:comment_6))
assert_not_includes(result, comments(:comment_5))
end

test "returns only comments associated to specified document_type" do
result = Searcher.search("コメント", document_type: :reports)
assert_equal [comments(:comment_11)], result
end

test "returns all comments when document_type is not specified" do
result = Searcher.search("コメント")
assert_includes(result, comments(:comment_8))
assert_includes(result, comments(:comment_10))
assert_includes(result, comments(:comment_11))
assert_includes(result, comments(:comment_12))
assert_includes(result, comments(:comment_13))
assert_includes(result, comments(:comment_14))
assert_equal(6, result.size)
end
end

0 comments on commit 28d8c80

Please sign in to comment.