Sha256: 2b2f8274e99c55547e5a805afe8799243331f5af58c987e589dda64a73e7caf2
Contents?: true
Size: 1.54 KB
Versions: 2
Compression:
Stored size: 1.54 KB
Contents
require 'spec_helper' module Spree describe LegacyUser, :type => :model do let(:user) { LegacyUser.new } it "can generate an API key" do expect(user).to receive(:save!) expect { user.generate_spree_api_key! }.to change(user, :spree_api_key).to be_present end it "can generate an API key without persisting" do expect(user).not_to receive(:save!) expect { user.generate_spree_api_key }.to change(user, :spree_api_key).to be_present end it "can clear an API key" do expect(user).to receive(:save!) user.clear_spree_api_key! expect(user.spree_api_key).to be_blank end context "admin role auto-api-key grant" do # so the admin user can do admin api actions let(:user) { create(:user) } before { expect(user.spree_roles).to be_blank } subject { user.spree_roles << role } context "admin role" do let(:role) { create(:role, name: "admin") } context "the user has no api key" do before { user.clear_spree_api_key! } it { expect { subject }.to change { user.reload.spree_api_key }.from(nil) } end context "the user already has an api key" do before { user.generate_spree_api_key! } it { expect { subject }.not_to change { user.reload.spree_api_key } } end end context "non-admin role" do let(:role) { create(:role, name: "foo") } before { user.clear_spree_api_key! } it { expect { subject }.not_to change { user.reload.spree_api_key } } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
solidus_api-1.0.7 | spec/models/spree/legacy_user_spec.rb |
solidus_api-1.0.6 | spec/models/spree/legacy_user_spec.rb |