Skip to content

Commit

Permalink
an organization can create a new request
Browse files Browse the repository at this point in the history
  • Loading branch information
Erin Joan Snyder authored and Erin Joan Snyder committed Jul 23, 2014
1 parent d1cd92a commit f6a1677
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 30 deletions.
3 changes: 1 addition & 2 deletions app/assets/stylesheets/style.css
Expand Up @@ -1088,5 +1088,4 @@ div .signup {

.menu ul li > ul li a:hover{
background-color:#2e2e2e;
}

}
47 changes: 19 additions & 28 deletions app/views/requests/new.html.erb
Expand Up @@ -4,60 +4,51 @@
<% end %>
<header class="fulfilled">Make a Request</header>
<%= form_for @request do |f| %>
<ul>
<li>
<div class="reqInput"><p id="rNeed"><%= f.hidden_field :organization, :value => @organization.name %></p></div>
</li>
<li><p id="organization_id" ><%= f.hidden_field :organization_id, :value => session[:organization_id] %></p></li>
<ul id="new_request_ul">
<li class="reqInput" id="rNeed"><%= f.hidden_field :organization, :value => @organization.name %></li>
<li id="organization_id"><%= f.hidden_field :organization_id, :value => session[:organization_id] %></li>
<li>
<% if flash[:resource] %>
<p class="error"> Resource Needed <%= flash[:resource].join(', and ') %></p>
<% end %>
<div class="reqLabel"><label>Resource Needed:</label></div>
<div class="reqInput"><p id="rNeed"><%= f.text_field :resource, :placeholder => "water bottles, blankets" %></p></div></li>
<p><label class="reqLabel">Resource Needed:</label> <%= f.text_field :resource, class: "reqInput", id: "rNeed", :placeholder => "water bottles, blankets" %></p></li>
<li>
<% if flash[:current_resource_count] %>
<p class="error" > Quantity Needed <%= flash[:current_resource_count].join(', and ') %></p>
<% end %>
<p><%= f.hidden_field :current_resource_count, :value => 0 %></p>
</li>

<br>
<li>
<% if flash[:target_resource_count] %>
<p class="error" > Quantity Needed <%= flash[:target_resource_count].join(', and ') %></p>
<% end %>
<div class="reqLabel"><label>Quantity Needed:</label></div>
<div class="reqInput"><p><%= f.text_field :target_resource_count, :placeholder => "500, 200" %></p></div>
</li>
<p><label class="reqLabel">Quantity Needed:</label> <%= f.text_field :target_resource_count, class: "reqInput", :placeholder => "500, 200" %></p></li>
<br>
<li>
<% if flash[:address] %>
<p class="error"> Address <%= flash[:address].join(', and ') %></p>
<% end %>
<div class="reqLabel"><label>Address:</label></div>
<div class="reqInput"><p><%= f.text_field :address, :placeholder => "1234 Valencia St, CA 94103" %></p></div>
</li>
<p><label class="reqLabel">Address:</label> <%= f.text_field :address, class: "reqInput", :placeholder => "1234 Valencia St, CA 94103" %></p></li>
<br>
<li>
<% if flash[:description] %>
<p class="error"> Description <%= flash[:description].join(', and ') %></p>
<% end %>
<div class="reqLabel"><label>Description:</label></div>
<div class="reqInput"><p><%= f.text_field :description, :placeholder => "Dehydrated Refugees" %></p></div>
</li>
<p><label class="reqLabel">Description:</label> <%= f.text_field :description, class: "reqInput", :placeholder => "Dehydrated Refugees" %></p></li>
<br>
<li>
<% if flash[:tag_list] %>
<p class="error"> Tag list <%= flash[:tag_list].join(', and ') %></p>
<% end %>
<div class="reqLabel"><label>Tag list:</label></div>
<div class="reqInput"><p><%= f.text_field :tag_list, :placeholder => "Clothing" %></p></div>
</li>
<li>
<div class="reqLabel"><label>Start Date: </label></div>
<div class="reqInput"><p><%= f.date_select :start_date %></p></div>
</li>
<li>
<div class="reqLabel"><label>End Date: </label></div>
<div class="reqInput"><p><%= f.date_select :end_date, :include_blank => true %></p></div>
</li>
<li><div class="formButtom"><p><%= f.submit 'Submit', :class => 'tfbutton'%></p></div></li>
<p><label class="reqLabel">Tag list:</label> <%= f.text_field :tag_list, class: "reqInput", :placeholder => "Clothing" %></p></li>
<br>
<li><p><label class="reqLabel">Start Date: </label>&nbsp;<%= f.date_select :start_date, class: "reqInput" %></p></li>
<br>
<li><p><label class="reqLabel">End Date: </label>&nbsp;<%= f.date_select :end_date, class: "reqInput", :include_blank => true %></p></li>
<br>
<li><p class="formButtom"><%= f.submit 'Submit', :class => 'tfbutton'%></p></li>
<% end %>
</ul>
</div>
33 changes: 33 additions & 0 deletions spec/features/new_request_spec.rb
@@ -0,0 +1,33 @@
require 'spec_helper'

feature 'Logged in organization' do
scenario 'can make a new request' do
FactoryGirl.create(:organization)
visit user_type_login_confirmation_sessions_path
fill_in 'Email', with: 'name@sample.org'
fill_in 'Password', with: 'password'
click_on 'Log In'
expect(page).to have_content("successful login!!")
click_on 'PROFILE'
expect(page).to have_content('Make New Request')
click_on 'Make New Request'
expect(page).to have_content('Make a Request')

within 'form#new_request' do
fill_in 'request[resource]', :with => 'pop tarts'
fill_in 'request[target_resource_count]', :with => 200
fill_in 'request[address]', :with => 'my house'
fill_in 'request[description]', :with => "I'm hungry and I want some pop tarts."
fill_in 'request[tag_list]', :with => 'erin'
select '2014', :from => 'request[start_date(1i)]'
select 'July', :from => 'request[start_date(2i)]', :match => :prefer_exact
select '23', :from => 'request[start_date(3i)]', :match => :prefer_exact
select '2015', :from => 'request[end_date(1i)]', :match => :first
select 'July', :from => 'request[end_date(2i)]', :match => :prefer_exact
select '23', :from => 'request[end_date(3i)]', :match => :prefer_exact
click_on 'Submit'
end
expect(page).to have_content("You have successfully created the request!")
expect(page).to_not have_content("Incorrect signup information for the request")
end
end

0 comments on commit f6a1677

Please sign in to comment.