Skip to content
Browse files

Merge commit 'fc907035ee423b47ef2ddbe5e98cd41df9650a93' into HEAD

  • Loading branch information...
2 parents 0c33000 + fc90703 commit b1099df049ae573e8490396056bc7fc14a37719a Jenkins committed May 29, 2012
View
2 Gemfile
@@ -36,7 +36,7 @@ gem "bson", "1.5.2"
if ENV['CONTENT_MODELS_DEV']
gem "govuk_content_models", :path => '../govuk_content_models'
else
- gem "govuk_content_models", "~> 0.0.11"
+ gem "govuk_content_models", "~> 0.0.12"
end
if ENV['BUNDLE_DEV']
View
4 Gemfile.lock
@@ -129,7 +129,7 @@ GEM
json
gherkin (2.7.3)
json (>= 1.4.6)
- govuk_content_models (0.0.11)
+ govuk_content_models (0.0.12)
bson_ext
differ
gds-api-adapters
@@ -291,7 +291,7 @@ DEPENDENCIES
gds-sso (~> 0.5)
gds-warmup-controller
gelf
- govuk_content_models (~> 0.0.11)
+ govuk_content_models (~> 0.0.12)
launchy
marples (~> 1.0)
minitest
View
35 config/initializers/messenger.rb
@@ -1,32 +1,17 @@
require 'messenger'
-require 'marples/model_action_broadcast'
-require 'artefact'
-class Artefact
- include Marples::ModelActionBroadcast
- self.marples_client_name = 'panopticon'
- self.marples_logger = Rails.logger
-end
-
-# Marples config needs to be triggered by on_prepare so it doesn't get merrily
-# blatted whenever the Artefact model reloads in development mode
-Panopticon::Application.config.to_prepare do
- if Rails.env.test? or ENV['NO_MESSENGER'].present?
- Messenger.transport = Marples::NullTransport.instance
- Artefact.marples_transport = Marples::NullTransport.instance
- else
- stomp_url = "failover://(stomp://support.cluster:61613,stomp://support.cluster:61613)"
+if Rails.env.test? or ENV['NO_MESSENGER'].present?
+ Messenger.transport = Marples::NullTransport.instance
+else
+ stomp_url = "failover://(stomp://support.cluster:61613,stomp://support.cluster:61613)"
- if defined?(PhusionPassenger)
- PhusionPassenger.on_event(:starting_worker_process) do |forked|
- if forked
- Messenger.transport = Stomp::Client.new stomp_url
- Artefact.marples_transport = Stomp::Client.new stomp_url
- end
+ if defined?(PhusionPassenger)
+ PhusionPassenger.on_event(:starting_worker_process) do |forked|
+ if forked
+ Messenger.transport = Stomp::Client.new stomp_url
end
- else
- Messenger.transport = Stomp::Client.new stomp_url
- Artefact.marples_transport = Stomp::Client.new stomp_url
end
+ else
+ Messenger.transport = Stomp::Client.new stomp_url
end
end
View
5 features/editing.feature
@@ -30,31 +30,27 @@ Feature: Editing artefacts
When I create a relationship between them
Then I should be redirected to Publisher
And the API should say that the artefacts are related
- And the rest of the system should be notified that the artefact has been updated
Scenario: Unassign a related item
Given two artefacts exist
And the artefacts are related
When I destroy their relationship
Then I should be redirected to Publisher
And the API should say that the artefacts are not related
- And the rest of the system should be notified that the artefact has been updated
Scenario: Assign additional related items
Given several artefacts exist
And some of the artefacts are related
When I create more relationships between them
Then I should be redirected to Publisher
And the API should say that more of the artefacts are related
- And the rest of the system should be notified that the artefact has been updated
# Scenario: Assign a contact
# Given an artefact exists
# And a contact exists
# When I add the contact to the artefact
# Then I should be redirected to Publisher
# And the API should say that the artefact has the contact
-# And the rest of the system should be notified that the artefact has been updated
# Scenario: Unassign a contact
# Given an artefact exists
@@ -63,7 +59,6 @@ Feature: Editing artefacts
# When I remove the contact from the artefact
# Then I should be redirected to Publisher
# And the API should say that the artefact does not have the contact
-# And the rest of the system should be notified that the artefact has been updated
Scenario: Add a section
Given an artefact exists
View
6 features/step_definitions/artefact_steps.rb
@@ -1,6 +1,5 @@
Given /^two artefacts exist$/ do
@artefact, @related_artefact = create_two_artefacts
- flush_notifications
end
When /^I mark relatedness as done$/ do
@@ -58,7 +57,6 @@
Given /^the artefacts are related$/ do
add_related_artefact @artefact, @related_artefact
- flush_notifications
end
When /^I destroy their relationship$/ do
@@ -69,12 +67,10 @@
Given /^several artefacts exist$/ do
@artefact, *@related_artefacts, @unrelated_artefact = create_six_artefacts
- flush_notifications
end
Given /^some of the artefacts are related$/ do
add_related_artefacts @artefact, @related_artefacts[0...(@related_artefacts.length / 2)]
- flush_notifications
end
When /^I create more relationships between them$/ do
@@ -85,7 +81,6 @@
Given /^an artefact exists$/ do
@artefact = create_artefact
- flush_notifications
end
Given /^a section exists$/ do
@@ -100,7 +95,6 @@
Given /^the artefact has the contact$/ do
add_contact @artefact, @contact
- flush_notifications
end
Given /^the artefact has the section$/ do
View
1 features/step_definitions/contact_steps.rb
@@ -1,4 +1,3 @@
Given /^a contact exists$/ do
@contact = create_contact
- flush_notifications
end
View
3 features/step_definitions/notification_steps.rb
@@ -1,3 +0,0 @@
-Then /^the rest of the system should be notified that the artefact has been updated$/ do
- check_update_notification @artefact
-end
View
6 features/support/fake_transport.rb
@@ -19,8 +19,4 @@ def publish(destination, message, headers = {})
attr_writer :notifications
end
-Artefact.marples_transport = Messenger.transport = FakeTransport.instance
-
-Before do
- flush_notifications
-end
+Messenger.transport = FakeTransport.instance
View
14 features/support/notifications.rb
@@ -1,14 +0,0 @@
-def flush_notifications
- FakeTransport.instance.flush
-end
-
-def latest_notification_with_destination(destination)
- notifications = FakeTransport.instance.notifications
- notifications.reverse.detect { |n| n[:destination] == destination }
-end
-
-def check_update_notification(artefact)
- notification = latest_notification_with_destination '/topic/marples.panopticon.artefacts.updated'
- assert_not_nil notification
- assert_equal artefact.slug, notification[:message][:artefact][:slug]
-end
View
13 lib/deleted_publication_listener.rb
@@ -1,13 +0,0 @@
-require "abstract_listener"
-
-class DeletedPublicationListener < AbstractListener
-
- listen 'publisher', '*', 'destroyed' do |publication, logger|
- logger.info "Found publication #{publication}"
- logger.info "Processing artefact #{publication['panopticon_id']}"
- artefact = Artefact.find(publication['panopticon_id'])
- logger.info 'Getting need ID from Panopticon'
- artefact.destroy
- logger.info 'Artefact destroyed'
- end
-end
View
25 test/unit/deleted_publication_listener_test.rb
@@ -1,25 +0,0 @@
-require "test_helper"
-require "deleted_publication_listener"
-
-class DeletedPublicationListenerTest < ActiveSupport::TestCase
- def mock_messenger
- mock("messenger").tap { |messenger|
- messenger.stubs(:join)
- messenger.stubs(:when)
- }
- end
-
- test "should destroy artefact when publication is deleted" do
- message = {"panopticon_id" => 1234}
-
- messenger = mock_messenger
- messenger.expects(:when).with("publisher", "*", "destroyed").yields(message)
-
- artefact = Artefact.new
- artefact.expects(:destroy)
- Artefact.expects(:find).with(1234).returns(artefact)
-
- DeletedPublicationListener.new(messenger, stub_everything).listen
- end
-end
-

0 comments on commit b1099df

Please sign in to comment.
Something went wrong with that request. Please try again.