Permalink
Browse files

Merge branch 'master' of git@github.com:railsrumble/giant-robots

  • Loading branch information...
2 parents abb63a1 + 62c4dc6 commit 2710733ba529994ab4ade94356737b61ec58c6f7 Micah Rich committed Oct 19, 2008
@@ -4,7 +4,11 @@ def body_class
end
def number_to_formatted_currency(number)
- number_to_currency(number, :unit => "<span class='dollar-sign'>$</span>")
+ if number.nil?
+ '?'
+ else
+ number_to_currency(number, :unit => "<span class='dollar-sign'>$</span>")
+ end
end
def user_name
View
@@ -40,9 +40,8 @@ def item_name_changed?
end
def cheapest_price
- item.
- cheapest_purchase_in_stores(user.nearby_stores).
- price
+ purchase = item.cheapest_purchase_in_stores(user.nearby_stores)
+ purchase.nil? ? nil : purchase.price
end
def self.per_page
@@ -1,7 +1,10 @@
<div id="account-changes">
<div class="signup-map" id="map" style="width: 475px; height: 169px;"></div>
- <% form_tag openid_path, :id => "openid_form" do %>
+ <% form_tag openid_path,
+ :id => "openid_form",
+ :style => "display: #{params[:user_type] == 'human' ? 'none' : 'block'};" do %>
+ <%= hidden_field_tag 'user_type', 'openid' %>
<div class="text_field">
<label for="openid_identifier">
Open ID <%= link_to_function "Login like a Human", "$('openid_form').hide(); $('new_user').show();" %>
@@ -18,7 +21,9 @@
</p>
<% end %>
- <% form_for @user, :html => { :style => "display: none;" } do |form| %>
+ <% form_for @user,
+ :html => { :style => "display: #{params[:user_type] == 'human' ? 'block' : 'none'};" } do |form| %>
+ <%= hidden_field_tag 'user_type', 'human' %>
<%= form.error_messages %>
<div class="text_field">
<label for="user_email">
@@ -16,3 +16,5 @@
# Disable delivery errors, bad email addresses will be ignored
config.action_mailer.raise_delivery_errors = false
+
+HOST = "wheresthemilkat.r08.railsrumble.com"
@@ -1,7 +1 @@
-ActionMailer::Base.smtp_settings = {
- :address => "smtp.thoughtbot.com",
- :port => 25,
- :domain => "thoughtbot.com"
-}
-
-DO_NOT_REPLY = "donotreply@wheresthemilk.at"
+DO_NOT_REPLY = "donotreply@wheresthemilkat.r08.railsrumble.com"
@@ -1,3 +1,3 @@
HoptoadNotifier.configure do |config|
- config.api_key = 'HOPTOAD-KEY'
+ config.api_key = 'b61f9924295cd6f481cef3696870e536'
end
@@ -15,6 +15,34 @@ class UsersControllerTest < ActionController::TestCase
should_have_map_observer map
end
end
+
+ context "POST to create as a human" do
+ setup do
+ post :create, :user_type => 'human'
+ end
+
+ should "display the human form" do
+ assert_select '#new_user[style="display: block;"]'
+ end
+
+ should "hide the openid form" do
+ assert_select '#openid_form[style="display: none;"]'
+ end
+ end
+
+ context "POST to create using openid" do
+ setup do
+ post :create, :user_type => 'openid'
+ end
+
+ should "hide the human form" do
+ assert_select '#new_user[style="display: none;"]'
+ end
+
+ should "display the openid form" do
+ assert_select '#openid_form[style="display: block;"]'
+ end
+ end
public_context do
context "with a user" do
@@ -6,6 +6,10 @@ class ApplicationHelperTest < ActionView::TestCase
assert_match /<span class='dollar-sign'>\$<\/span>3.25/, number_to_formatted_currency(3.25)
end
+ should "produce '?' when sent #number_to_formatted_currency with nil" do
+ assert_equal '?', number_to_formatted_currency(nil)
+ end
+
context "when sent #autocomplete_field" do
context "from XHR" do
setup do
View
@@ -195,4 +195,26 @@ class PurchaseTest < Test::Unit::TestCase
assert_equal price, purchase.cheapest_price
end
+
+ context "with no nearby Stores" do
+ setup do
+ @purchase = Factory(:purchase)
+ stores = mock('stores')
+ price = 100.00
+
+ @purchase.item.
+ expects(:cheapest_purchase_in_stores).
+ with(stores).
+ returns(nil)
+
+ @purchase.user.
+ expects(:nearby_stores).
+ with().
+ returns(stores)
+ end
+
+ should "produce nil when sent #cheapest_price" do
+ assert_nil @purchase.cheapest_price
+ end
+ end
end

0 comments on commit 2710733

Please sign in to comment.