spec/auth/user_spec.rb in ddr-models-1.15.0 vs spec/auth/user_spec.rb in ddr-models-1.16.0

- old
+ new

@@ -4,9 +4,28 @@ module Auth RSpec.describe User, type: :model do subject { FactoryGirl.build(:user) } + describe "delegation to ability" do + it "should delegate `can`" do + expect(subject.ability).to receive(:can).with(:edit, "foo") + subject.can :edit, "foo" + end + it "should delegate `cannot`" do + expect(subject.ability).to receive(:cannot).with(:edit, "foo") + subject.cannot :edit, "foo" + end + it "should delegate `can?`" do + expect(subject.ability).to receive(:can?).with(:edit, "foo") + subject.can? :edit, "foo" + end + it "should delegate `cannot?`" do + expect(subject.ability).to receive(:cannot?).with(:edit, "foo") + subject.cannot? :edit, "foo" + end + end + describe "#member_of?" do before do allow(subject).to receive(:groups) { [Group.new("foo"), Group.new("bar")] } end it "should return true if the user is a member of the group" do