From 4c2534d12e805638bcb70e1c1e13de351527f607 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Mon, 26 Aug 2024 11:53:48 -0400 Subject: [PATCH] Convert "static page" controller specs to system specs (#31599) --- spec/controllers/about_controller_spec.rb | 17 ------------ spec/controllers/home_controller_spec.rb | 30 --------------------- spec/controllers/privacy_controller_spec.rb | 14 ---------- spec/system/about_spec.rb | 12 +++++++++ spec/system/home_spec.rb | 25 +++++++++++++++++ spec/system/privacy_spec.rb | 12 +++++++++ 6 files changed, 49 insertions(+), 61 deletions(-) delete mode 100644 spec/controllers/about_controller_spec.rb delete mode 100644 spec/controllers/home_controller_spec.rb delete mode 100644 spec/controllers/privacy_controller_spec.rb create mode 100644 spec/system/about_spec.rb create mode 100644 spec/system/home_spec.rb create mode 100644 spec/system/privacy_spec.rb diff --git a/spec/controllers/about_controller_spec.rb b/spec/controllers/about_controller_spec.rb deleted file mode 100644 index 8db6d80b0b..0000000000 --- a/spec/controllers/about_controller_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -require 'rails_helper' - -RSpec.describe AboutController do - render_views - - describe 'GET #show' do - before do - get :show - end - - it 'returns http success' do - expect(response).to have_http_status(200) - end - end -end diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb deleted file mode 100644 index 50a8aba2d8..0000000000 --- a/spec/controllers/home_controller_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -require 'rails_helper' - -RSpec.describe HomeController do - render_views - - describe 'GET #index' do - subject { get :index } - - context 'when not signed in' do - it 'returns http success' do - request.path = '/' - expect(subject).to have_http_status(:success) - end - end - - context 'when signed in' do - let(:user) { Fabricate(:user) } - - before do - sign_in(user) - end - - it 'returns http success' do - expect(subject).to have_http_status(:success) - end - end - end -end diff --git a/spec/controllers/privacy_controller_spec.rb b/spec/controllers/privacy_controller_spec.rb deleted file mode 100644 index c92c71ea64..0000000000 --- a/spec/controllers/privacy_controller_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -require 'rails_helper' - -describe PrivacyController do - render_views - - describe 'GET #show' do - it 'returns http success' do - get :show - expect(response).to have_http_status(200) - end - end -end diff --git a/spec/system/about_spec.rb b/spec/system/about_spec.rb new file mode 100644 index 0000000000..dc976b91e0 --- /dev/null +++ b/spec/system/about_spec.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe 'About page' do + it 'visits the about page and renders the web app' do + visit about_path + + expect(page) + .to have_css('noscript', text: /Mastodon/) + end +end diff --git a/spec/system/home_spec.rb b/spec/system/home_spec.rb new file mode 100644 index 0000000000..08b9737d6b --- /dev/null +++ b/spec/system/home_spec.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe 'Home page' do + context 'when signed in' do + before { sign_in Fabricate(:user) } + + it 'visits the homepage and renders the web app' do + visit root_path + + expect(page) + .to have_css('noscript', text: /Mastodon/) + end + end + + context 'when not signed in' do + it 'visits the homepage and renders the web app' do + visit root_path + + expect(page) + .to have_css('noscript', text: /Mastodon/) + end + end +end diff --git a/spec/system/privacy_spec.rb b/spec/system/privacy_spec.rb new file mode 100644 index 0000000000..f2ab1310cc --- /dev/null +++ b/spec/system/privacy_spec.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe 'Privacy policy page' do + it 'visits the privacy policy page and renders the web app' do + visit privacy_policy_path + + expect(page) + .to have_css('noscript', text: /Mastodon/) + end +end