Sha256: 7fda5fa75ef473373a4fb0934021079d11dfddadbb80cab0110f67f219ca3376

Contents?: true

Size: 1.25 KB

Versions: 13

Compression:

Stored size: 1.25 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 }
      spree_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
      spree_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
        spree_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
      spree_put :update, user: { spree_role_ids: [role.id] }
      expect(assigns[:user].spree_roles).to_not include role
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
spree_auth_devise-3.2.0.beta spec/controllers/spree/users_controller_spec.rb
solidus_auth_devise-1.5.0 spec/controllers/spree/users_controller_spec.rb
solidus_auth_devise-1.4.0 spec/controllers/spree/users_controller_spec.rb
spree_auth_devise-3.1.0 spec/controllers/spree/users_controller_spec.rb
spree_auth_devise-3.0.6 spec/controllers/spree/users_controller_spec.rb
spree_auth_devise-3.0.5 spec/controllers/spree/users_controller_spec.rb
solidus_auth_devise-1.3.0 spec/controllers/spree/users_controller_spec.rb
solidus_auth_devise-1.2.3 spec/controllers/spree/users_controller_spec.rb
solidus_auth_devise-1.2.2 spec/controllers/spree/users_controller_spec.rb
solidus_auth_devise-1.2.1 spec/controllers/spree/users_controller_spec.rb
solidus_auth_devise-1.2.0 spec/controllers/spree/users_controller_spec.rb
solidus_auth_devise-1.1.0 spec/controllers/spree/users_controller_spec.rb
solidus_auth_devise-1.0.0 spec/controllers/spree/users_controller_spec.rb