mirror of
https://github.com/discourse/discourse.git
synced 2024-11-28 04:13:44 +08:00
89ad2b5900
This updates tests to use latest rails 5 practice and updates ALL dependencies that could be updated Performance testing shows that performance has not regressed if anything it is marginally faster now.
62 lines
1.5 KiB
Ruby
62 lines
1.5 KiB
Ruby
require 'rails_helper'
|
|
|
|
RSpec.describe Admin::SearchLogsController do
|
|
let(:admin) { Fabricate(:admin) }
|
|
let(:user) { Fabricate(:user) }
|
|
|
|
before do
|
|
SearchLog.log(term: 'ruby', search_type: :header, ip_address: '127.0.0.1')
|
|
end
|
|
|
|
after do
|
|
SearchLog.clear_debounce_cache!
|
|
end
|
|
|
|
context "#index" do
|
|
it "raises an error if you aren't logged in" do
|
|
get '/admin/logs/search_logs.json'
|
|
expect(response.status).to eq(404)
|
|
end
|
|
|
|
it "raises an error if you aren't an admin" do
|
|
sign_in(user)
|
|
get '/admin/logs/search_logs.json'
|
|
expect(response.status).to eq(404)
|
|
end
|
|
|
|
it "should work if you are an admin" do
|
|
sign_in(admin)
|
|
get '/admin/logs/search_logs.json'
|
|
|
|
expect(response).to be_successful
|
|
|
|
json = ::JSON.parse(response.body)
|
|
expect(json[0]['term']).to eq('ruby')
|
|
end
|
|
end
|
|
|
|
context "#term" do
|
|
it "raises an error if you aren't logged in" do
|
|
get '/admin/logs/search_logs/term/ruby.json'
|
|
expect(response.status).to eq(404)
|
|
end
|
|
|
|
it "raises an error if you aren't an admin" do
|
|
sign_in(user)
|
|
get '/admin/logs/search_logs/term/ruby.json'
|
|
expect(response.status).to eq(404)
|
|
end
|
|
|
|
it "should work if you are an admin" do
|
|
sign_in(admin)
|
|
get '/admin/logs/search_logs/term/ruby.json'
|
|
|
|
expect(response).to be_successful
|
|
|
|
json = ::JSON.parse(response.body)
|
|
expect(json['term']['type']).to eq('search_log_term')
|
|
expect(json['term']['search_result']).to be_present
|
|
end
|
|
end
|
|
end
|