From 26f34add6494c6762e1e27914dfbd6e37cd0aa02 Mon Sep 17 00:00:00 2001 From: Matthew Rider Date: Thu, 29 Aug 2024 15:20:45 +0200 Subject: [PATCH] [improvement]: favor request specs, reduce created contributors (#2001) --- spec/requests/admin/stats_spec.rb | 29 +++++++++++++++++++++++++++++ spec/system/admin/stats_spec.rb | 29 ----------------------------- 2 files changed, 29 insertions(+), 29 deletions(-) create mode 100644 spec/requests/admin/stats_spec.rb delete mode 100644 spec/system/admin/stats_spec.rb diff --git a/spec/requests/admin/stats_spec.rb b/spec/requests/admin/stats_spec.rb new file mode 100644 index 000000000..415a1e9b7 --- /dev/null +++ b/spec/requests/admin/stats_spec.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe 'Stats' do + context 'as admin' do + subject { -> { get admin_stats_path(as: user) } } + let(:user) { create(:user, admin: true) } + let(:mock_validator) { instance_double(ThreemaValidator) } + + before do + create_list(:contributor, 1) + create_list(:contributor, 1, :threema_contributor, :skip_validations) + create_list(:contributor, 2, :telegram_contributor) + create_list(:contributor, 1, :signal_contributor) + create_list(:contributor, 2, :signal_contributor_uuid) + create_list(:contributor, 6, :whats_app_contributor) + subject.call + end + + it 'admin edits contributor', flaky: true do + expect(page).to have_content('Email contributors: 1') + expect(page).to have_content('Threema contributors: 1') + expect(page).to have_content('Telegram contributors: 2') + expect(page).to have_content('Signal contributors: 3') + expect(page).to have_content('WhatsApp contributors: 6') + end + end +end diff --git a/spec/system/admin/stats_spec.rb b/spec/system/admin/stats_spec.rb deleted file mode 100644 index da70358aa..000000000 --- a/spec/system/admin/stats_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -require 'rails_helper' - -RSpec.describe 'Stats' do - context 'as admin' do - let(:user) { create(:user, admin: true) } - let(:mock_validator) { instance_double(ThreemaValidator) } - - before do - create_list(:contributor, 3) - create_list(:contributor, 2, :threema_contributor, :skip_validations) - create_list(:contributor, 4, :telegram_contributor) - create_list(:contributor, 2, :signal_contributor) - create_list(:contributor, 4, :signal_contributor_uuid) - create_list(:contributor, 12, :whats_app_contributor) - end - - it 'admin edits contributor', flaky: true do - visit admin_stats_path(as: user) - - expect(page).to have_content('Email contributors: 3') - expect(page).to have_content('Threema contributors: 2') - expect(page).to have_content('Telegram contributors: 4') - expect(page).to have_content('Signal contributors: 6') - expect(page).to have_content('WhatsApp contributors: 12') - end - end -end