rubocop: fix style warnings
This commit is contained in:
@@ -62,9 +62,9 @@ module Searchable
|
||||
])
|
||||
end
|
||||
|
||||
# Models must implement these methods:
|
||||
# - search_title: returns title string or nil
|
||||
# - search_content: returns content string
|
||||
# - search_card_id: returns the card id (self.id for cards, card_id for comments)
|
||||
# - search_board_id: returns the board id
|
||||
# Models must implement these methods:
|
||||
# - search_title: returns title string or nil
|
||||
# - search_content: returns content string
|
||||
# - search_card_id: returns the card id (self.id for cards, card_id for comments)
|
||||
# - search_board_id: returns the board id
|
||||
end
|
||||
|
||||
@@ -28,8 +28,8 @@ class Search::Highlighter
|
||||
if words.length <= max_words
|
||||
highlight(text)
|
||||
elsif match_index
|
||||
start_index = [0, match_index - max_words / 2].max
|
||||
end_index = [words.length - 1, start_index + max_words - 1].min
|
||||
start_index = [ 0, match_index - max_words / 2 ].max
|
||||
end_index = [ words.length - 1, start_index + max_words - 1 ].min
|
||||
|
||||
snippet_text = words[start_index..end_index].join(" ")
|
||||
snippet_text = "...#{snippet_text}" if start_index > 0
|
||||
@@ -50,7 +50,7 @@ class Search::Highlighter
|
||||
terms << phrase.first
|
||||
end
|
||||
|
||||
unquoted = query.gsub(/"[^"]+"/, '')
|
||||
unquoted = query.gsub(/"[^"]+"/, "")
|
||||
unquoted.split(/\s+/).each do |word|
|
||||
terms << word if word.present?
|
||||
end
|
||||
|
||||
@@ -27,16 +27,16 @@ class Card::SearchableTest < ActiveSupport::TestCase
|
||||
# Searching by comment
|
||||
card_with_comment = @board.cards.create!(title: "Some card", creator: @user)
|
||||
card_with_comment.comments.create!(body: "overflowing text", creator: @user)
|
||||
results = Card.mentioning("overflowing", user: @user )
|
||||
results = Card.mentioning("overflowing", user: @user)
|
||||
assert_includes results, card_with_comment
|
||||
|
||||
# Sanitizing search query
|
||||
card_broken = @board.cards.create!(title: "broken layout", creator: @user)
|
||||
results = Card.mentioning("broken \"", user: @user )
|
||||
results = Card.mentioning("broken \"", user: @user)
|
||||
assert_includes results, card_broken
|
||||
|
||||
# Empty query returns no results
|
||||
assert_empty Card.mentioning("\"", user: @user )
|
||||
assert_empty Card.mentioning("\"", user: @user)
|
||||
|
||||
# Filtering by board_ids
|
||||
other_board = Board.create!(name: "Other Board", account: @account, creator: @user)
|
||||
|
||||
@@ -23,7 +23,7 @@ class IdentityTest < ActiveSupport::TestCase
|
||||
identity = identities(:david)
|
||||
account = accounts(:initech)
|
||||
|
||||
assert_difference ["Membership.count", "User.count"], 1 do
|
||||
assert_difference [ "Membership.count", "User.count" ], 1 do
|
||||
identity.join(account)
|
||||
end
|
||||
|
||||
|
||||
+1
-1
@@ -81,7 +81,7 @@ module FixturesTestHelper
|
||||
end
|
||||
|
||||
# Rails passes :string for varchar columns, so handle both :uuid and :string
|
||||
return super(label, column_type) unless column_type.in?([:uuid, :string])
|
||||
return super(label, column_type) unless column_type.in?([ :uuid, :string ])
|
||||
generate_fixture_uuid(label)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user