# frozen_string_literal: true module Symphonia describe UsersController, type: 'controller' do routes { Symphonia::Engine.routes } subject { Symphonia::User } let(:user) { FactoryBot.create(:user) } context 'as admin', logged: :admin do include ActiveJob::TestHelper include_examples 'a controller actions', :user context 'not found' do it '#show' do get :show, params: { id: 0 } expect(response).to have_http_status :not_found end end it '#archive' do user.update_columns status: 'active' expect(post(:archive, params: { id: user })) expect(response).to redirect_to users_url expect(user.reload.status).to eq 'archived' end it '#unarchive' do user.update_columns status: 'archived' expect(post(:unarchive, params: { id: user })) expect(ActionMailer::MailDeliveryJob).to have_been_enqueued expect(response).to redirect_to users_url expect(user.reload.status).to eq 'active' end end context 'as regular use', logged: true do it '#index' do get :index expect(response).to have_http_status :forbidden end end end end