mirror of
https://github.com/Retrospring/retrospring.git
synced 2024-11-20 10:19:52 +01:00
Add request spec for report indicator
This commit is contained in:
parent
92c9ed011f
commit
99faf075ff
2 changed files with 53 additions and 0 deletions
|
@ -70,6 +70,7 @@ RSpec.configure do |config|
|
|||
config.include Devise::Test::ControllerHelpers, type: :controller
|
||||
config.include Devise::Test::ControllerHelpers, type: :helper
|
||||
config.include Devise::Test::ControllerHelpers, type: :view
|
||||
config.include Devise::Test::IntegrationHelpers, type: :request
|
||||
config.include ViewComponent::TestHelpers, type: :component
|
||||
config.include ViewComponent::SystemTestHelpers, type: :component
|
||||
end
|
||||
|
|
52
spec/requests/new_reports_spec.rb
Normal file
52
spec/requests/new_reports_spec.rb
Normal file
|
@ -0,0 +1,52 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe "New reports indicator", type: :request do
|
||||
let(:user) { FactoryBot.create(:user, roles: [:moderator]) }
|
||||
|
||||
before do
|
||||
sign_in user
|
||||
end
|
||||
|
||||
subject { get "/" }
|
||||
|
||||
describe "setting an assign for new reports" do
|
||||
context "never visited the reports listing before" do
|
||||
it "sets a assign" do
|
||||
subject
|
||||
|
||||
expect(assigns["has_new_reports"]).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
context "visited the reports listing, with no new reports" do
|
||||
before do
|
||||
user.last_reports_visit = DateTime.now
|
||||
user.save
|
||||
end
|
||||
|
||||
it "sets a assign" do
|
||||
subject
|
||||
|
||||
expect(assigns["has_new_reports"]).to eq(false)
|
||||
end
|
||||
end
|
||||
|
||||
context "visited the reports listing, with new reports" do
|
||||
let(:other_user) { FactoryBot.create :user }
|
||||
|
||||
before do
|
||||
Report.create(user:, target_id: other_user.id, target_user_id: other_user.id, type: "Reports::User", created_at: DateTime.now)
|
||||
user.last_reports_visit = DateTime.now - 1.day
|
||||
user.save
|
||||
end
|
||||
|
||||
it "sets a assign" do
|
||||
subject
|
||||
|
||||
expect(assigns["has_new_reports"]).to eq(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue