Skip to content
This repository has been archived by the owner on Oct 12, 2018. It is now read-only.

Commit

Permalink
Fix display of unpublished related links
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiecobbett committed Jun 15, 2012
1 parent b0d861a commit 9a973b6
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 38 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Expand Up @@ -35,13 +35,13 @@ gem "bson", "1.5.2"
if ENV['CONTENT_MODELS_DEV'] if ENV['CONTENT_MODELS_DEV']
gem "govuk_content_models", :path => '../govuk_content_models' gem "govuk_content_models", :path => '../govuk_content_models'
else else
gem "govuk_content_models", "~> 0.0.14" gem "govuk_content_models", "~> 0.0.18"
end end


if ENV['BUNDLE_DEV'] if ENV['BUNDLE_DEV']
gem 'gds-sso', :path => '../gds-sso' gem 'gds-sso', :path => '../gds-sso'
else else
gem 'gds-sso', '~> 0.6' gem 'gds-sso', '0.5'
end end


group :assets do group :assets do
Expand Down
45 changes: 24 additions & 21 deletions Gemfile.lock
Expand Up @@ -100,36 +100,38 @@ GEM
factory_girl (~> 2.4.0) factory_girl (~> 2.4.0)
railties (>= 3.0.0) railties (>= 3.0.0)
fakeweb (1.3.0) fakeweb (1.3.0)
faraday (0.8.1) faraday (0.7.6)
addressable (~> 2.2)
multipart-post (~> 1.1) multipart-post (~> 1.1)
rack (~> 1.1)
ffi (1.0.11) ffi (1.0.11)
gds-api-adapters (0.0.47) gds-api-adapters (0.0.47)
lrucache (~> 0.1.1) lrucache (~> 0.1.1)
null_logger null_logger
plek plek
gds-sso (0.6.0) gds-sso (0.5.0)
omniauth-gds (= 0.0.2) oa-core (~> 0.3.2)
oa-oauth (~> 0.3.2)
oauth2 (= 0.5.2)
rack (= 1.3.5) rack (= 1.3.5)
rack-accept (~> 0.4.4) rack-accept (~> 0.4.4)
rails (>= 3.0.0) rails (>= 3.0.0)
warden (~> 1.2) warden (= 1.0.6)
gds-warmup-controller (0.0.2) gds-warmup-controller (0.0.2)
rails (>= 3.0.0) rails (>= 3.0.0)
gelf (1.3.2) gelf (1.3.2)
json json
gherkin (2.7.3) gherkin (2.7.3)
json (>= 1.4.6) json (>= 1.4.6)
govuk_content_models (0.0.14) govuk_content_models (0.0.18)
bson_ext bson_ext
differ differ
gds-api-adapters gds-api-adapters
gds-sso gds-sso (~> 0.5.0)
mongoid (~> 2.4.10) mongoid (~> 2.4.10)
plek (~> 0.1.22) plek (~> 0.1.22)
state_machine state_machine
hashie (1.2.0)
hike (1.2.1) hike (1.2.1)
httpauth (0.1)
i18n (0.6.0) i18n (0.6.0)
json (1.7.3) json (1.7.3)
launchy (2.0.5) launchy (2.0.5)
Expand Down Expand Up @@ -162,23 +164,24 @@ GEM
mongo (~> 1.3) mongo (~> 1.3)
tzinfo (~> 0.3.22) tzinfo (~> 0.3.22)
multi_json (1.0.4) multi_json (1.0.4)
multi_xml (0.4.4)
multipart-post (1.1.5) multipart-post (1.1.5)
net-http-digest_auth (1.2) net-http-digest_auth (1.2)
net-http-persistent (1.9) net-http-persistent (1.9)
nokogiri (1.5.0) nokogiri (1.5.0)
null_logger (0.0.1) null_logger (0.0.1)
oauth2 (0.6.0) oa-core (0.3.2)
oa-oauth (0.3.2)
faraday (~> 0.7.3)
multi_json (~> 1.0.0)
multi_xml (~> 0.4.0)
oa-core (= 0.3.2)
oauth (~> 0.4.0)
oauth2 (~> 0.5.0)
oauth (0.4.6)
oauth2 (0.5.2)
faraday (~> 0.7) faraday (~> 0.7)
httpauth (~> 0.1)
multi_json (~> 1.0) multi_json (~> 1.0)
omniauth (1.1.0)
hashie (~> 1.2)
rack
omniauth-gds (0.0.2)
omniauth-oauth2 (~> 1.0)
omniauth-oauth2 (1.0.2)
oauth2 (~> 0.6.0)
omniauth (~> 1.0)
plek (0.1.22) plek (0.1.22)
builder builder
polyglot (0.3.3) polyglot (0.3.3)
Expand Down Expand Up @@ -247,7 +250,7 @@ GEM
uglifier (1.2.2) uglifier (1.2.2)
execjs (>= 0.3.0) execjs (>= 0.3.0)
multi_json (>= 1.0.2) multi_json (>= 1.0.2)
warden (1.2.0) warden (1.0.6)
rack (>= 1.0) rack (>= 1.0)
webrobots (0.0.12) webrobots (0.0.12)
nokogiri (>= 1.4.4) nokogiri (>= 1.4.4)
Expand Down Expand Up @@ -278,10 +281,10 @@ DEPENDENCIES
formtastic! formtastic!
formtastic-bootstrap! formtastic-bootstrap!
gds-api-adapters gds-api-adapters
gds-sso (~> 0.6) gds-sso (= 0.5)
gds-warmup-controller gds-warmup-controller
gelf gelf
govuk_content_models (~> 0.0.14) govuk_content_models (~> 0.0.18)
launchy launchy
marples (~> 1.0) marples (~> 1.0)
minitest minitest
Expand Down
2 changes: 1 addition & 1 deletion app/views/artefacts/_form.html.erb
Expand Up @@ -16,7 +16,7 @@
<%= semantic_form_for(artefact, :html => { :class => '', :id => 'edit_artefact'}) do |f| %> <%= semantic_form_for(artefact, :html => { :class => '', :id => 'edit_artefact'}) do |f| %>
<%= f.inputs do %> <%= f.inputs do %>
<%= f.input :name, :input_html => { :class => "span6" } %> <%= f.input :name, :input_html => { :class => "span6" } %>
<%= f.input :slug, :input_html => { :class => "span6", :disabled => f.object.any_editions_published? }, :hint => "A valid slug might look like this: i-am-a-good-slug-with-no-spaces" %> <%= f.input :slug, :input_html => { :class => "span6", :disabled => f.object.any_editions_ever_published? }, :hint => "A valid slug might look like this: i-am-a-good-slug-with-no-spaces" %>
<%= f.input :need_id, :input_html => { :class => "span6", :disabled => f.object.persisted? } %> <%= f.input :need_id, :input_html => { :class => "span6", :disabled => f.object.persisted? } %>
<% if ! artefact.new_record? && ! artefact.business_proposition %> <% if ! artefact.new_record? && ! artefact.business_proposition %>
<%= link_to "View in Need-O-Tron", need_url(f.object), :rel => 'external', :class => "btn btn-primary" %> <%= link_to "View in Need-O-Tron", need_url(f.object), :rel => 'external', :class => "btn btn-primary" %>
Expand Down
12 changes: 6 additions & 6 deletions features/editing.feature
Expand Up @@ -26,10 +26,10 @@ Feature: Editing artefacts
Then I should be redirected to Publisher Then I should be redirected to Publisher


Scenario: Assign a related item Scenario: Assign a related item
Given two artefacts exist Given two non-publisher artefacts exist
When I create a relationship between them When I create a relationship between them
Then I should be redirected to Publisher And I save
And the API should say that the artefacts are related Then the API should say that the artefacts are related


Scenario: Unassign a related item Scenario: Unassign a related item
Given two artefacts exist Given two artefacts exist
Expand All @@ -39,11 +39,11 @@ Feature: Editing artefacts
And the API should say that the artefacts are not related And the API should say that the artefacts are not related


Scenario: Assign additional related items Scenario: Assign additional related items
Given several artefacts exist Given several non-publisher artefacts exist
And some of the artefacts are related And some of the artefacts are related
When I create more relationships between them When I create more relationships between them
Then I should be redirected to Publisher And I save
And the API should say that more of the artefacts are related Then the API should say that more of the artefacts are related


# Scenario: Assign a contact # Scenario: Assign a contact
# Given an artefact exists # Given an artefact exists
Expand Down
10 changes: 6 additions & 4 deletions features/step_definitions/artefact_steps.rb
Expand Up @@ -2,6 +2,10 @@
@artefact, @related_artefact = create_two_artefacts @artefact, @related_artefact = create_two_artefacts
end end


Given /^two non-publisher artefacts exist$/ do
@artefact, @related_artefact = create_two_artefacts("smart-answers")
end

When /^I mark relatedness as done$/ do When /^I mark relatedness as done$/ do
check :relatedness_done check :relatedness_done
end end
Expand Down Expand Up @@ -48,7 +52,6 @@
When /^I create a relationship between them$/ do When /^I create a relationship between them$/ do
visit edit_artefact_path(@artefact) visit edit_artefact_path(@artefact)
select_related_artefact @related_artefact select_related_artefact @related_artefact
submit_artefact_form
end end


Then /^I should be redirected to (.*)$/ do |app| Then /^I should be redirected to (.*)$/ do |app|
Expand All @@ -65,8 +68,8 @@
submit_artefact_form submit_artefact_form
end end


Given /^several artefacts exist$/ do Given /^several non-publisher artefacts exist$/ do
@artefact, *@related_artefacts, @unrelated_artefact = create_six_artefacts @artefact, *@related_artefacts, @unrelated_artefact = create_six_artefacts("smart-answers")
end end


Given /^some of the artefacts are related$/ do Given /^some of the artefacts are related$/ do
Expand All @@ -76,7 +79,6 @@
When /^I create more relationships between them$/ do When /^I create more relationships between them$/ do
visit edit_artefact_path(@artefact) visit edit_artefact_path(@artefact)
select_related_artefacts @related_artefacts[(@related_artefacts.length / 2)..-1] select_related_artefacts @related_artefacts[(@related_artefacts.length / 2)..-1]
submit_artefact_form
end end


Given /^an artefact exists$/ do Given /^an artefact exists$/ do
Expand Down
8 changes: 4 additions & 4 deletions features/support/artefacts.rb
Expand Up @@ -2,22 +2,22 @@ def create_artefact
Factory.create :artefact, :name => 'Child Benefit rates', :need_id => 1 Factory.create :artefact, :name => 'Child Benefit rates', :need_id => 1
end end


def create_two_artefacts def create_two_artefacts(owning_app="publisher")
[ [
'Probation', 'Probation',
'Leaving prison' 'Leaving prison'
].map { |name| Factory.create :artefact, :name => name, :need_id => 1 } ].map { |name| Factory.create :artefact, :name => name, :need_id => 1, owning_app: owning_app }
end end


def create_six_artefacts def create_six_artefacts(owning_app="publisher")
[ [
'Driving disqualifications', 'Driving disqualifications',
'Book the practical driving test', 'Book the practical driving test',
'Driving before your licence is returned', 'Driving before your licence is returned',
'National Driver Offender Retraining Scheme', 'National Driver Offender Retraining Scheme',
'Apply for a new driving licence', 'Apply for a new driving licence',
'Get a divorce' 'Get a divorce'
].map { |name| Factory.create :artefact, :name => name, :need_id => 1 } ].map { |name| Factory.create :artefact, :name => name, :need_id => 1, owning_app: owning_app }
end end


def add_related_artefact(artefact, related_artefact) def add_related_artefact(artefact, related_artefact)
Expand Down

0 comments on commit 9a973b6

Please sign in to comment.