Add tests for toggling unmask
This commit is contained in:
parent
93f8bf35d2
commit
a9cfa3fccc
1
Gemfile
1
Gemfile
|
@ -95,6 +95,7 @@ group :development, :test do
|
|||
gem "rspec-sidekiq", "~> 3.0", require: false
|
||||
gem "rubocop", "~> 1.22", ">= 1.22.1"
|
||||
gem "rubocop-rails", "~> 2.13", ">= 2.13.1"
|
||||
gem "shoulda-matchers", "~> 5.0"
|
||||
gem "simplecov", require: false
|
||||
gem "simplecov-cobertura", require: false
|
||||
gem "simplecov-json", require: false
|
||||
|
|
|
@ -515,6 +515,8 @@ GEM
|
|||
sentry-ruby-core (~> 5.2.1)
|
||||
sidekiq (>= 3.0)
|
||||
shellany (0.0.1)
|
||||
shoulda-matchers (5.1.0)
|
||||
activesupport (>= 5.2.0)
|
||||
sidekiq (5.2.10)
|
||||
connection_pool (~> 2.2, >= 2.2.2)
|
||||
rack (~> 2.0)
|
||||
|
@ -659,6 +661,7 @@ DEPENDENCIES
|
|||
sentry-rails
|
||||
sentry-ruby
|
||||
sentry-sidekiq
|
||||
shoulda-matchers (~> 5.0)
|
||||
sidekiq (< 6)
|
||||
simplecov
|
||||
simplecov-cobertura
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "rails_helper"
|
||||
|
||||
describe ModerationController, type: :controller do
|
||||
describe "#toggle_unmask" do
|
||||
let(:user) { FactoryBot.create(:user, roles: [:moderator]) }
|
||||
|
||||
before do
|
||||
sign_in(user)
|
||||
post :toggle_unmask, session: { moderation_view: moderation_view }
|
||||
end
|
||||
|
||||
context "when moderation view flag is true" do
|
||||
let(:moderation_view) { true }
|
||||
|
||||
it { is_expected.to set_session[:moderation_view].to(false) }
|
||||
|
||||
it { is_expected.to redirect_to(root_path) }
|
||||
end
|
||||
|
||||
context "when moderation view flag is false" do
|
||||
let(:moderation_view) { false }
|
||||
|
||||
it { is_expected.to set_session[:moderation_view].to(true) }
|
||||
end
|
||||
|
||||
context "when moderation view flag is not set" do
|
||||
let(:moderation_view) { nil }
|
||||
|
||||
it { is_expected.to set_session[:moderation_view].to(true) }
|
||||
end
|
||||
end
|
||||
end
|
|
@ -80,4 +80,11 @@ RSpec.configure do |config|
|
|||
config.include Devise::Test::ControllerHelpers, type: :helper
|
||||
end
|
||||
|
||||
Shoulda::Matchers.configure do |config|
|
||||
config.integrate do |with|
|
||||
with.test_framework :rspec
|
||||
with.library :rails
|
||||
end
|
||||
end
|
||||
|
||||
Dir[Rails.root.join "spec", "shared_examples", "*.rb"].sort.each { |f| require f }
|
||||
|
|
Loading…
Reference in New Issue