Sha256: 7ea48f871c1bb2e9f64b88b51eab9b11810b930479fcbaee508c862b9ba146f7

Contents?: true

Size: 1.22 KB

Versions: 3

Compression:

Stored size: 1.22 KB

Contents

RSpec.describe Spree::UsersController, type: :controller do

  let(:admin_user) { create(:user) }
  let(:user) { create(:user) }
  let(:role) { create(:role) }

  before { allow(controller).to receive(:spree_current_user) { user } }

  context '#load_object' do
    it 'redirects to signup path if user is not found' do
      allow(controller).to receive(:spree_current_user) { nil }
      put :update, { user: { email: 'foobar@example.com' } }
      expect(response).to redirect_to spree.login_path
    end
  end

  context '#create' do
    it 'creates a new user' do
      post :create, { user: { email: 'foobar@example.com', password: 'foobar123', password_confirmation: 'foobar123' } }
      expect(assigns[:user].new_record?).to be false
    end
  end

  context '#update' do
    context 'when updating own account' do
      it 'performs update' do
        put :update, { user: { email: 'mynew@email-address.com' } }
        expect(assigns[:user].email).to eq 'mynew@email-address.com'
        expect(response).to redirect_to spree.account_url(only_path: true)
      end
    end

    it 'does not update roles' do
      put :update, user: { spree_role_ids: [role.id] }
      expect(assigns[:user].spree_roles).to_not include role
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
solidus_auth_devise-1.6.2 spec/controllers/spree/users_controller_spec.rb
solidus_auth_devise-1.6.1 spec/controllers/spree/users_controller_spec.rb
solidus_auth_devise-1.6.0 spec/controllers/spree/users_controller_spec.rb