-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only publish manuals if its the correct version
As we are now queueing manuals for publishing we need to protect against changes happening between an editor clicking Publish and the worker actually performing the publish. We also add the version number to the logs as its useful information to know about.
- Loading branch information
Andrew Mitchell
committed
Aug 14, 2014
1 parent
947126a
commit 83dbfcd
Showing
12 changed files
with
74 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
class AsynchronousManualServiceRegistry | ||
|
||
def publish(id) | ||
PublishManualWorker.perform_async(id) | ||
def publish(id, version_number) | ||
PublishManualWorker.perform_async(id, version_number) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,7 @@ | |
organisation_slug: "organisation_slug", | ||
state: "draft", | ||
slug: manual_slug, | ||
version_number: 1, | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
require "fast_spec_helper" | ||
require "publish_manual_service" | ||
|
||
RSpec.describe PublishManualService do | ||
|
||
let(:manual_id) { double(:manual_id) } | ||
let(:manual_repository) { double(:manual_repository) } | ||
let(:listeners) { [] } | ||
let(:manual) { double(:manual, version_number: 3) } | ||
|
||
subject { | ||
PublishManualService.new( | ||
manual_id: manual_id, | ||
manual_repository: manual_repository, | ||
listeners: listeners, | ||
version_number: version_number, | ||
) | ||
} | ||
|
||
before do | ||
allow(manual_repository).to receive(:fetch) { manual } | ||
allow(manual_repository).to receive(:store) | ||
allow(manual).to receive(:publish) | ||
end | ||
|
||
context "when the version number is up to date" do | ||
let(:version_number) { 3 } | ||
|
||
it "publishes the manual" do | ||
subject.call | ||
expect(manual).to have_received(:publish) | ||
end | ||
end | ||
|
||
context "when the version numbers differ" do | ||
let(:version_number) { 4 } | ||
|
||
it "does not publish the manual" do | ||
subject.call | ||
expect(manual).to_not have_received(:publish) | ||
end | ||
end | ||
end |