mirror of
https://github.com/discourse/discourse.git
synced 2025-06-05 14:07:30 +08:00
Add rubocop to our build. (#5004)
This commit is contained in:
@ -166,12 +166,10 @@ describe Search do
|
||||
let(:reply) { Fabricate(:post, topic: topic,
|
||||
raw: 'hello from mars, we just landed') }
|
||||
|
||||
|
||||
|
||||
it 'searches correctly' do
|
||||
|
||||
expect do
|
||||
Search.execute('mars', type_filter: 'private_messages')
|
||||
Search.execute('mars', type_filter: 'private_messages')
|
||||
end.to raise_error(Discourse::InvalidAccess)
|
||||
|
||||
TopicAllowedUser.create!(user_id: reply.user_id, topic_id: topic.id)
|
||||
@ -183,7 +181,6 @@ describe Search do
|
||||
|
||||
expect(results.posts.length).to eq(1)
|
||||
|
||||
|
||||
results = Search.execute('mars',
|
||||
search_context: topic,
|
||||
guardian: Guardian.new(reply.user))
|
||||
@ -200,7 +197,6 @@ describe Search do
|
||||
Fabricate(:topic, category_id: nil, archetype: 'private_message')
|
||||
Fabricate(:post, topic: topic, raw: 'another secret pm from mars, testing')
|
||||
|
||||
|
||||
# admin can search everything with correct context
|
||||
results = Search.execute('mars',
|
||||
type_filter: 'private_messages',
|
||||
@ -235,8 +231,7 @@ describe Search do
|
||||
|
||||
context 'topics' do
|
||||
let(:post) { Fabricate(:post) }
|
||||
let(:topic) { post.topic}
|
||||
|
||||
let(:topic) { post.topic }
|
||||
|
||||
context 'search within topic' do
|
||||
|
||||
@ -311,7 +306,7 @@ describe Search do
|
||||
end
|
||||
|
||||
context "search for a topic by url" do
|
||||
let(:result) { Search.execute(topic.relative_url, search_for_id: true, type_filter: 'topic')}
|
||||
let(:result) { Search.execute(topic.relative_url, search_for_id: true, type_filter: 'topic') }
|
||||
|
||||
it 'returns the topic' do
|
||||
expect(result.posts.length).to eq(1)
|
||||
@ -331,7 +326,7 @@ describe Search do
|
||||
topic.category_id = category.id
|
||||
topic.save
|
||||
|
||||
category.set_permissions(:staff => :full)
|
||||
category.set_permissions(staff: :full)
|
||||
category.save
|
||||
|
||||
expect(result(nil).posts).not_to be_present
|
||||
@ -345,11 +340,11 @@ describe Search do
|
||||
|
||||
context 'cyrillic topic' do
|
||||
let!(:cyrillic_topic) { Fabricate(:topic) do
|
||||
user
|
||||
user
|
||||
title { sequence(:title) { |i| "Тестовая запись #{i}" } }
|
||||
end
|
||||
end
|
||||
}
|
||||
let!(:post) {Fabricate(:post, topic: cyrillic_topic, user: cyrillic_topic.user)}
|
||||
let!(:post) { Fabricate(:post, topic: cyrillic_topic, user: cyrillic_topic.user) }
|
||||
let(:result) { Search.execute('запись') }
|
||||
|
||||
it 'finds something when given cyrillic query' do
|
||||
@ -380,13 +375,11 @@ describe Search do
|
||||
|
||||
end
|
||||
|
||||
|
||||
context 'type_filter' do
|
||||
|
||||
let!(:user) { Fabricate(:user, username: 'amazing', email: 'amazing@amazing.com') }
|
||||
let!(:category) { Fabricate(:category, name: 'amazing category', user: user) }
|
||||
|
||||
|
||||
context 'user filter' do
|
||||
let(:results) { Search.execute('amazing', type_filter: 'user') }
|
||||
|
||||
@ -435,12 +428,12 @@ describe Search do
|
||||
subcategory = Fabricate(:category, parent_category_id: category.id)
|
||||
sub_topic = Fabricate(:topic, category: subcategory)
|
||||
|
||||
post = Fabricate(:post, topic: topic, user: topic.user )
|
||||
_another_post = Fabricate(:post, topic: topic_no_cat, user: topic.user )
|
||||
sub_post = Fabricate(:post, raw: 'I am saying hello from a subcategory', topic: sub_topic, user: topic.user )
|
||||
post = Fabricate(:post, topic: topic, user: topic.user)
|
||||
_another_post = Fabricate(:post, topic: topic_no_cat, user: topic.user)
|
||||
sub_post = Fabricate(:post, raw: 'I am saying hello from a subcategory', topic: sub_topic, user: topic.user)
|
||||
|
||||
search = Search.execute('hello', search_context: category)
|
||||
expect(search.posts.map(&:id).sort).to eq([post.id,sub_post.id].sort)
|
||||
expect(search.posts.map(&:id).sort).to eq([post.id, sub_post.id].sort)
|
||||
expect(search.posts.length).to eq(2)
|
||||
end
|
||||
|
||||
@ -450,7 +443,7 @@ describe Search do
|
||||
it 'splits English / Chinese' do
|
||||
SiteSetting.default_locale = 'zh_CN'
|
||||
data = Search.prepare_data('Discourse社区指南').split(' ')
|
||||
expect(data).to eq(['Discourse', '社区','指南'])
|
||||
expect(data).to eq(['Discourse', '社区', '指南'])
|
||||
end
|
||||
|
||||
it 'finds chinese topic based on title' do
|
||||
@ -711,9 +704,9 @@ describe Search do
|
||||
let(:topic1) { Fabricate(:topic, tags: [tag2, Fabricate(:tag)]) }
|
||||
let(:topic2) { Fabricate(:topic, tags: [tag2]) }
|
||||
let(:topic3) { Fabricate(:topic, tags: [tag1, tag2]) }
|
||||
let!(:post1) { Fabricate(:post, topic: topic1)}
|
||||
let!(:post2) { Fabricate(:post, topic: topic2)}
|
||||
let!(:post3) { Fabricate(:post, topic: topic3)}
|
||||
let!(:post1) { Fabricate(:post, topic: topic1) }
|
||||
let!(:post2) { Fabricate(:post, topic: topic2) }
|
||||
let!(:post3) { Fabricate(:post, topic: topic3) }
|
||||
|
||||
it 'can find posts with tag' do
|
||||
post4 = Fabricate(:post, topic: topic3, raw: "It probably doesn't help that they're green...")
|
||||
@ -757,7 +750,6 @@ describe Search do
|
||||
expect(Search.word_to_date('january')).to eq(Time.zone.parse('2001-01-01'))
|
||||
expect(Search.word_to_date('jan')).to eq(Time.zone.parse('2001-01-01'))
|
||||
|
||||
|
||||
expect(Search.word_to_date('100')).to eq(time.beginning_of_day.days_ago(100))
|
||||
|
||||
expect(Search.word_to_date('invalid')).to eq(nil)
|
||||
|
Reference in New Issue
Block a user