Sha256: 0ce702c2a62bdf3e6441c0bbf1f6418d60394ddbe8537c962f995ba5b50b277d
Contents?: true
Size: 1.81 KB
Versions: 1
Compression:
Stored size: 1.81 KB
Contents
require 'spec_helper' RSpec.describe Spree::DevicesController, type: :controller do context 'when there are 3 user devices' do before :each do user = create(:user, email: FFaker::Internet.email, password: FFaker::Internet.password) allow(controller).to receive(:spree_current_user).and_return(user) device1 = create(:device) device2 = create(:device) device3 = create(:device) @user_device1 = create(:user_device, user: user, device: device1) @user_device2 = create(:user_device, user: user, device: device2) @user_device3 = create(:user_device, user: user, device: device3) end it 'lists user devices' do get :index expect(response.status).to eq 200 expect(response).to render_template('index') end it 'deletes user device' do delete :destroy, params: { id: @user_device3.device.id } expect(response.status).to eq 302 expect(response).to redirect_to(devices_url) expect(Spree::Device.count).to eq 2 expect(Spree::UserDevice.count).to eq 2 end end context 'when there are two users on the same device' do it 'deletes user device' do user1 = create(:user, email: FFaker::Internet.email, password: FFaker::Internet.password) user2 = create(:user, email: FFaker::Internet.email, password: FFaker::Internet.password) allow(controller).to receive(:spree_current_user).and_return(user1) device = create(:device) user_device1 = create(:user_device, user: user1, device: device) create(:user_device, user: user2, device: device) delete :destroy, params: { id: user_device1.device.id } expect(response.status).to eq 302 expect(response).to redirect_to(devices_url) expect(Spree::Device.count).to eq 1 expect(Spree::UserDevice.count).to eq 1 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
spree_devices-1.2.0 | spec/controllers/devices_controller_spec.rb |