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

Commit

Permalink
Allow creation of business items
Browse files Browse the repository at this point in the history
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
jystewart committed Mar 21, 2012
1 parent 27ddcda commit d9d445a
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 4 deletions.
6 changes: 4 additions & 2 deletions app/controllers/artefacts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/views/artefacts/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
Expand Down
3 changes: 3 additions & 0 deletions app/views/artefacts/index.html.erb
Original file line number Diff line number Diff line change
@@ -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>
Expand Down
19 changes: 19 additions & 0 deletions features/direct_creation.feature
Original file line number Diff line number Diff line change
@@ -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
30 changes: 29 additions & 1 deletion features/step_definitions/artefact_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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.