Sha256: ce0e84161d6f679eb941cc7665927ca897e70c146abaa7bfc376f9c7d5bc74cc

Contents?: true

Size: 1.21 KB

Versions: 31

Compression:

Stored size: 1.21 KB

Contents

# 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

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
symphonia-6.0.5 spec/controllers/users_controller_spec.rb
symphonia-6.0.2 spec/controllers/users_controller_spec.rb
symphonia-6.0.1 spec/controllers/users_controller_spec.rb
symphonia-6.0.0 spec/controllers/users_controller_spec.rb
symphonia-5.0.6 spec/controllers/users_controller_spec.rb
symphonia-5.0.5 spec/controllers/users_controller_spec.rb
symphonia-5.0.4 spec/controllers/users_controller_spec.rb
symphonia-5.0.3 spec/controllers/users_controller_spec.rb
symphonia-5.0.0 spec/controllers/users_controller_spec.rb
symphonia-4.2.0 spec/controllers/users_controller_spec.rb
symphonia-4.1.3 spec/controllers/users_controller_spec.rb
symphonia-4.1.2 spec/controllers/users_controller_spec.rb
symphonia-4.1.1 spec/controllers/users_controller_spec.rb
symphonia-4.1.0 spec/controllers/users_controller_spec.rb
symphonia-4.0.1 spec/controllers/users_controller_spec.rb
symphonia-4.0.0 spec/controllers/users_controller_spec.rb
symphonia-3.4.0 spec/controllers/users_controller_spec.rb
symphonia-3.3.4 spec/controllers/users_controller_spec.rb
symphonia-3.3.3 spec/controllers/users_controller_spec.rb
symphonia-3.3.2 spec/controllers/users_controller_spec.rb