2015-10-11 05:41:23 -04:00
|
|
|
require 'rails_helper'
|
2015-07-15 08:54:28 -04:00
|
|
|
|
|
|
|
describe Admin::PermalinksController do
|
|
|
|
|
|
|
|
it "is a subclass of AdminController" do
|
|
|
|
expect(Admin::PermalinksController < Admin::AdminController).to eq(true)
|
|
|
|
end
|
|
|
|
|
2018-06-11 00:37:21 -04:00
|
|
|
let(:admin) { Fabricate(:admin) }
|
2015-07-15 08:54:28 -04:00
|
|
|
|
2018-06-11 00:37:21 -04:00
|
|
|
before do
|
|
|
|
sign_in(admin)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#index' do
|
2015-07-15 08:54:28 -04:00
|
|
|
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")
|
|
|
|
|
2018-06-11 00:37:21 -04:00
|
|
|
get "/admin/permalinks.json", params: { filter: "topic" }
|
2015-07-15 08:54:28 -04:00
|
|
|
|
2018-06-07 04:11:09 -04:00
|
|
|
expect(response.status).to eq(200)
|
2015-07-15 08:54:28 -04:00
|
|
|
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")
|
|
|
|
|
2018-06-11 00:37:21 -04:00
|
|
|
get "/admin/permalinks.json", params: { filter: "discourse" }
|
2015-07-15 08:54:28 -04:00
|
|
|
|
2018-06-07 04:11:09 -04:00
|
|
|
expect(response.status).to eq(200)
|
2015-07-15 08:54:28 -04:00
|
|
|
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")
|
|
|
|
|
2018-06-11 00:37:21 -04:00
|
|
|
get "/admin/permalinks.json", params: { filter: "discourse" }
|
2015-07-15 08:54:28 -04:00
|
|
|
|
2018-06-07 04:11:09 -04:00
|
|
|
expect(response.status).to eq(200)
|
2015-07-15 08:54:28 -04:00
|
|
|
result = JSON.parse(response.body)
|
|
|
|
expect(result.length).to eq(3)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|