discourse/spec/controllers/admin/permalinks_controller_spec.rb
Sam 89ad2b5900 DEV: Rails 5.2 upgrade and global gem upgrade
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.
2018-06-07 14:21:33 +10:00

52 lines
1.7 KiB
Ruby

require 'rails_helper'
describe Admin::PermalinksController do
it "is a subclass of AdminController" do
expect(Admin::PermalinksController < Admin::AdminController).to eq(true)
end
let!(:user) { log_in(:admin) }
describe 'index' do
it 'filters url' do
Fabricate(:permalink, url: "/forum/23")
Fabricate(:permalink, url: "/forum/98")
Fabricate(:permalink, url: "/discuss/topic/45")
Fabricate(:permalink, url: "/discuss/topic/76")
get :index, params: { filter: "topic" }, format: :json
expect(response).to be_successful
result = JSON.parse(response.body)
expect(result.length).to eq(2)
end
it 'filters external url' do
Fabricate(:permalink, external_url: "http://google.com")
Fabricate(:permalink, external_url: "http://wikipedia.org")
Fabricate(:permalink, external_url: "http://www.discourse.org")
Fabricate(:permalink, external_url: "http://try.discourse.org")
get :index, params: { filter: "discourse" }, format: :json
expect(response).to be_successful
result = JSON.parse(response.body)
expect(result.length).to eq(2)
end
it 'filters url and external url both' do
Fabricate(:permalink, url: "/forum/23", external_url: "http://google.com")
Fabricate(:permalink, url: "/discourse/98", external_url: "http://wikipedia.org")
Fabricate(:permalink, url: "/discuss/topic/45", external_url: "http://discourse.org")
Fabricate(:permalink, url: "/discuss/topic/76", external_url: "http://try.discourse.org")
get :index, params: { filter: "discourse" }, format: :json
expect(response).to be_successful
result = JSON.parse(response.body)
expect(result.length).to eq(3)
end
end
end