Sha256: f9a9adfc75f271d83888b5d96e97c3311b32d97efdb5c351ac5d9e62656fd9a8

Contents?: true

Size: 1.22 KB

Versions: 7

Compression:

Stored size: 1.22 KB

Contents

# require_relative '../spec_helper.rb'
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::DeliveryJob).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

7 entries across 7 versions & 1 rubygems

Version Path
symphonia-3.0.3 spec/controllers/users_controller_spec.rb
symphonia-3.0.2 spec/controllers/users_controller_spec.rb
symphonia-2.2.1 spec/controllers/users_controller_spec.rb
symphonia-3.0.1 spec/controllers/users_controller_spec.rb
symphonia-3.0.0 spec/controllers/users_controller_spec.rb
symphonia-2.1.8 spec/controllers/users_controller_spec.rb
symphonia-2.1.7 spec/controllers/users_controller_spec.rb