Permalink
Browse files

Allow creation of business items

Added a cucumber story to test adding an item without an existing need id, and made minor adjustments to make it pass. There's some more work to do to decide how we want to flag business items here and/or in publisher
  • Loading branch information...
1 parent 27ddcda commit d9d445a3798147011dbabed81671722f142e3c00 @jystewart jystewart committed Mar 21, 2012
@@ -48,8 +48,10 @@ def update
private
def redirect_to_show_if_need_met
- artefact = Artefact.find_by_need_id params[:artefact][:need_id]
- redirect_to artefact if artefact.present?
+ if params[:artefact] and params[:artefact][:need_id]
+ artefact = Artefact.find_by_need_id params[:artefact][:need_id]
+ redirect_to artefact if artefact.present?
+ end
end
def find_artefact
@@ -14,7 +14,7 @@
<%= semantic_form_for(artefact, :html => { :class => 'artefact' }) do |f| %>
<%= f.inputs :name => "Basic information" do %>
<%= f.input :name %>
- <%= f.input :slug, :input_html => { :disabled => true } %>
+ <%= f.input :slug, :input_html => { :disabled => f.object.persisted? } %>
<%= f.input :section, :as => :select, :collection => Artefact.sections.map {|s| [s.gsub(':', ' > '), s] } %>
<% end %>
<%= f.inputs "Related items", :class => "related" do %>
@@ -1,5 +1,8 @@
<h2>Everything We Have</h2>
+<p class="buttons">
+ <%= link_to 'Add item', new_artefact_path %>
+</p>
<table id="solution-list" border="2">
<thead>
<tr>
@@ -0,0 +1,19 @@
+Feature: Creating artefacts directly
+ In order to support multiple propositions
+ I want to create artefacts directly in panopticon
+ So I am not prematurely committed to need-o-tron
+
+ Background:
+ Given I am an admin
+
+ Scenario:
+ When I visit the homepage
+ Then I should see a link to create an item
+
+ When I follow the link link to create an item
+ Then I should see the artefact form
+
+ When I fill in the form for a business need
+ And I save, indicating that I want to go to the item
+
+ Then I should be redirected to Publisher
@@ -34,6 +34,10 @@
click_button 'Save and continue editing'
end
+When /^I save, indicating that I want to go to the item$/ do
+ click_button 'Save and go to item'
+end
+
Then /^I should see the edit form again$/ do
assert page.has_css?('form.artefact')
end
@@ -49,7 +53,7 @@
end
Then /^I should be redirected to (.*)$/ do |app|
- check_redirect app, @artefact
+ check_redirect app, (@artefact || Artefact.last)
end
Given /^the artefacts are related$/ do
@@ -100,3 +104,27 @@
unselect_contact @contact
submit_artefact_form
end
+
+When /^I visit the homepage$/ do
+ visit root_path
+end
+
+Then /^I should see a link to create an item$/ do
+ xpath = "//a[@href='#{new_artefact_path}']"
+ assert page.has_xpath?(xpath)
+end
+
+When /^I follow the link link to create an item$/ do
+ visit new_artefact_path
+end
+
+Then /^I should see the artefact form$/ do
+ assert page.has_css?('form.artefact')
+end
+
+When /^I fill in the form for a business need$/ do
+ fill_in "Name", with: "A key business need"
+ fill_in "Slug", with: "key-business-need"
+ fill_in "Need", with: "Biz001"
+ select "answer", from: "Kind"
+end

0 comments on commit d9d445a

Please sign in to comment.