From 12b1687e1f17aac2a635902719c62b52233c5592 Mon Sep 17 00:00:00 2001 From: OsamaSayegh Date: Mon, 11 Jun 2018 07:37:21 +0300 Subject: [PATCH] REFACTOR: admin permalinks controller specs to requests (#5970) --- .../admin/permalinks_controller_spec.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) rename spec/{controllers => requests}/admin/permalinks_controller_spec.rb (83%) diff --git a/spec/controllers/admin/permalinks_controller_spec.rb b/spec/requests/admin/permalinks_controller_spec.rb similarity index 83% rename from spec/controllers/admin/permalinks_controller_spec.rb rename to spec/requests/admin/permalinks_controller_spec.rb index 1084eed2103..c0fa35abde4 100644 --- a/spec/controllers/admin/permalinks_controller_spec.rb +++ b/spec/requests/admin/permalinks_controller_spec.rb @@ -6,16 +6,20 @@ describe Admin::PermalinksController do expect(Admin::PermalinksController < Admin::AdminController).to eq(true) end - let!(:user) { log_in(:admin) } + let(:admin) { Fabricate(:admin) } - describe 'index' do + before do + sign_in(admin) + end + + 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 + get "/admin/permalinks.json", params: { filter: "topic" } expect(response.status).to eq(200) result = JSON.parse(response.body) @@ -28,7 +32,7 @@ describe Admin::PermalinksController do Fabricate(:permalink, external_url: "http://www.discourse.org") Fabricate(:permalink, external_url: "http://try.discourse.org") - get :index, params: { filter: "discourse" }, format: :json + get "/admin/permalinks.json", params: { filter: "discourse" } expect(response.status).to eq(200) result = JSON.parse(response.body) @@ -41,7 +45,7 @@ describe Admin::PermalinksController do 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 + get "/admin/permalinks.json", params: { filter: "discourse" } expect(response.status).to eq(200) result = JSON.parse(response.body)