Skip to content
Permalink
Browse files

ProductLicense#{accept!,reject!} does not return anything

  • Loading branch information...
imobachgs committed Apr 5, 2018
1 parent 5b85533 commit b9b77ff62e79cbbfcc9435470aa7ef351db1cc4e
@@ -85,28 +85,24 @@ def initialize(product_name, license, source: nil)
#
# @return [Boolean] true if the license has been accepted; false otherwise.
def accepted?
license.accepted?
sync_acceptance
license.accepted?
end

# Accept the license
#
# As a side effect, it will update the source acceptance
#
# @return [Boolean] true if the license has been accepted; false otherwise.
def accept!
license.accept!
sync_acceptance
license.accepted?
nil
end

# Reject the license
#
# @return [Boolean] true if the license has been accepted; false otherwise.
def reject!
license.reject!
sync_acceptance
license.accepted?
nil
end

private
@@ -96,16 +96,21 @@
product_license.accept!
end

it "returns true" do
expect(product_license.accept!).to eq(true)
end

context "when a handler for the source is given" do
it "synchronizes the source" do
expect(handler).to receive(:confirmation=).with(true)
product_license.accept!
end
end

context "when a handler was not given" do
let(:handler) { nil }

it "does not try to synchronize the status and does not crash" do
expect(license).to receive(:accept!).and_call_original
product_license.accept!
end
end
end

describe "#reject!" do
@@ -116,27 +121,61 @@
product_license.reject!
end

it "returns false" do
expect(product_license.reject!).to eq(false)
end

context "when a handler for the source is given" do
it "synchronizes the source" do
expect(handler).to receive(:confirmation=).with(false)
product_license.reject!
end
end

context "when a handler was not given" do
let(:handler) { nil }

it "does not try to synchronize the status and does not crash" do
expect(license).to receive(:reject!).and_call_original
product_license.reject!
end
end
end

describe "#accepted?" do
context "if the product license has been accepted" do
it "returns true"
before do
allow(license).to receive(:accepted?).and_return(accepted?)
end

context "if the product license has been accepted" do
it "returns false"
let(:accepted?) { true }

it "returns true" do
expect(product_license).to be_accepted
end

it "synchronizes the source" do
expect(handler).to receive(:confirmation=).with(true)
product_license.reject!
end
end

context "synchronizes the license status"
context "if the product license has not been accepted" do
let(:accepted?) { false }

it "returns false" do
expect(product_license).to_not be_accepted
end

it "synchronizes the source" do
expect(handler).to receive(:confirmation=).with(false)
product_license.reject!
end
end

context "when a handler was not given" do
let(:handler) { nil }
let(:accepted?) { true }

it "does not try to synchronize the status and does not crash" do
product_license.accepted?
end
end
end
end

0 comments on commit b9b77ff

Please sign in to comment.
You can’t perform that action at this time.