Here is my factory:
factory :acceptance do
favor
user
accepted false
end
and here is my request spec:
describe "to acceptances" do
let (:favor) { create(:favor, user: user) }
let (:acceptance) { create(:acceptance, user: user, favor: favor)}
context "when has accepted acceptance" do
it "shold not allow sending more acceptances" do
acceptance.accepted = true
expect(permission.allow?(:acceptances, :create, favor)).to be false
end
The problem is with acceptance.accepted = true
. As I figured out, this is not setting the accepted
attribute to be true
. How can I achive this?
Thanks a lot for your time!
You need to save the record, otherwise you've only changed the local copy of acceptance. add acceptance.save
or update_attribute
will do the save for you.
describe "to acceptances" do
let (:favor) { create(:favor, user: user) }
let (:acceptance) { create(:acceptance, user: user, favor: favor)}
context "when has accepted acceptance" do
it "shold not allow sending more acceptances" do
acceptance.update_attribute(:accepted, true)
expect(permission.allow?(:acceptances, :create, favor)).to be false
end
end
end