From 450a60072182168910a6a719a378bac9b7c512e2 Mon Sep 17 00:00:00 2001 From: OsamaSayegh Date: Tue, 22 May 2018 06:40:50 +0300 Subject: [PATCH] REFACTOR: about & badge controllers => requests --- .../{controllers => requests}/about_controller_spec.rb | 8 ++++---- .../badges_controller_spec.rb | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) rename spec/{controllers => requests}/about_controller_spec.rb (87%) rename spec/{controllers => requests}/badges_controller_spec.rb (82%) diff --git a/spec/controllers/about_controller_spec.rb b/spec/requests/about_controller_spec.rb similarity index 87% rename from spec/controllers/about_controller_spec.rb rename to spec/requests/about_controller_spec.rb index 647e50c4976..e4e4b01a0a2 100644 --- a/spec/controllers/about_controller_spec.rb +++ b/spec/requests/about_controller_spec.rb @@ -6,22 +6,22 @@ describe AboutController do it "should display the about page for anonymous user when login_required is false" do SiteSetting.login_required = false - get :index + get "/about" expect(response).to be_success end it 'should redirect to login page for anonymous user when login_required is true' do SiteSetting.login_required = true - get :index + get "/about" expect(response).to redirect_to '/login' end it "should display the about page for logged in user when login_required is true" do SiteSetting.login_required = true - log_in - get :index + sign_in(Fabricate(:user)) + get "/about" expect(response).to be_success end diff --git a/spec/controllers/badges_controller_spec.rb b/spec/requests/badges_controller_spec.rb similarity index 82% rename from spec/controllers/badges_controller_spec.rb rename to spec/requests/badges_controller_spec.rb index de894666c6b..2b03b23e38f 100644 --- a/spec/controllers/badges_controller_spec.rb +++ b/spec/requests/badges_controller_spec.rb @@ -10,7 +10,7 @@ describe BadgesController do context 'index' do it 'should return a list of all badges' do - get :index, format: :json + get "/badges.json" expect(response.status).to eq(200) parsed = JSON.parse(response.body) @@ -20,22 +20,22 @@ describe BadgesController do context 'show' do it "should return a badge" do - get :show, params: { id: badge.id }, format: :json + get "/badges/#{badge.id}.json" expect(response.status).to eq(200) parsed = JSON.parse(response.body) expect(parsed["badge"]).to be_present end it "should mark the notification as viewed" do - log_in_user(user) + sign_in(user) user_badge = BadgeGranter.grant(badge, user) expect(user_badge.notification.read).to eq(false) - get :show, params: { id: badge.id } + get "/badges/#{badge.id}.json" expect(user_badge.notification.reload.read).to eq(true) end it 'renders rss feed of a badge' do - get :show, params: { id: badge.id }, format: :rss + get "/badges/#{badge.id}.rss" expect(response.status).to eq(200) expect(response.content_type).to eq('application/rss+xml') end