Skip to content

Commit

Permalink
updated locales a bit and improved front end wholesaler capy test
Browse files Browse the repository at this point in the history
  • Loading branch information
citrus committed May 28, 2011
1 parent 64f45f3 commit 9872b53
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 132 deletions.
12 changes: 8 additions & 4 deletions app/views/wholesalers/_fields.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<% end %>
</fieldset>

<fieldset class="company-details">
<fieldset class="wholesaler-details">
<legend>Company Information</legend>

<%= render "shared/error_messages", :target => @wholesaler %>
Expand All @@ -31,24 +31,28 @@
</p>
<p>
<%= form.label :fax %><br/>
<%= form.text_field :fax, :class => 'required' %><span class="req">*</span>
<%= form.text_field :fax %>
</p>
<p>
<%= form.label :resale_number %><br/>
<%= form.text_field :resale_number, :class => 'required' %><span class="req">*</span>
<%= form.text_field :resale_number %>
</p>
<p>
<%= form.label :taxid %><br/>
<%= form.text_field :taxid, :class => 'required' %><span class="req">*</span>
</p>
<p>
<%= form.label :web_address %><br/>
<%= form.text_field :web_address, :class => 'required' %><span class="req">*</span>
<%= form.text_field :web_address %>
</p>
<p>
<%= form.label :terms %><br/>
<%= form.select :terms, Wholesaler.term_options, :class => 'required' %><span class="req">*</span>
</p>
<p>
<%= form.label :notes %><br/>
<%= form.text_area :notes %>
</p>
</fieldset>
</fieldset>

Expand Down
2 changes: 1 addition & 1 deletion app/views/wholesalers/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1>Wholesale Signup</h1>
<h1><%= t('wholesale_signup') %></h1>

<%= form_for @wholesaler do |form| %>
Expand Down
3 changes: 3 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ en:
listing_wholesalers: "Listing Wholesaler"
wholesale_login: "Wholesale Login"
wholesale_apply: "Apply for a wholesale account"
wholesale_signup: Wholesale Signup



Expand All @@ -33,6 +34,8 @@ en:


wholesaler:
signup_success: Thank you for your interest in becoming a wholesaler! We'll be in touch shortly.
signup_failed: Wholesale account could not be created!
parts_error_message: There are errors with the user or addresses


Expand Down
4 changes: 2 additions & 2 deletions lib/spree_wholesale/wholesaler_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ module ClassMethods
# Overwrite point

def after_wholesaler_create
flash[:notice] = "Thank you for your interest in becoming a wholesaler! We'll be in touch shortly."
flash[:notice] = I18n.t('wholesaler.signup_success')
redirect_to wholesalers_path
end

def after_wholesaler_failed_create
flash[:error] = "Wholesale account could not be created!"
flash[:error] = I18n.t('wholesaler.signup_failed')
render :action => :new
end

Expand Down
179 changes: 54 additions & 125 deletions test/integration/wholesalers_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,133 +23,62 @@ def setup
assert has_link?("Apply Now!")
click_link "Apply Now!"
assert_equal new_wholesaler_path, current_path
end

sleep 10

should "get new wholesaler" do
visit new_wholesaler_path
assert has_content?(I18n.t('wholesale_signup'))
within "#new_wholesaler" do
@labels.each do |f|
assert has_field?(f)
end
assert has_field?('Terms')
end
assert has_button?(I18n.t('wholesale_apply'))
end

end
should "validate wholesaler and parts" do
visit new_wholesaler_path
click_button I18n.t('wholesale_apply')
assert_flash(:errors, I18n.t('wholesaler.signup_failed'))
assert_seen "6 errors prohibited this record from being saved:", :within => ".wholesaler-details .errorExplanation"
assert_seen I18n.t("wholesaler.parts_error_message"), :within => ".wholesaler-details .errorExplanation"
end

#should "get new wholesaler" do
# visit new_wholesaler_path
# assert has_content?("New Wholesaler")
# within "#new_wholesaler" do
# @labels.each do |f|
# assert has_field?(f)
# end
# assert has_field?('Terms')
# end
#end
#
#should "validate wholesaler and parts" do
# visit new_wholesaler_path
# click_button "Create"
# assert_flash(:error, I18n.t('admin.wholesalers.failed'))
# assert_seen I18n.t("wholesaler.parts_error_message"), :within => ".errorExplanation"
#end
#
#should "be a valid wholesaler but invalid parts" do
# visit new_wholesaler_path
# @labels.each_with_index do |label, index|
# fill_in label, :with => @values[index]
# end
# select 'Credit Card', :from => 'Terms'
# click_button "Create"
# assert_flash(:error, I18n.t('admin.wholesalers.failed'))
# assert_seen I18n.t("wholesaler.parts_error_message"), :within => ".errorExplanation"
#end
#
#should "create wholesaler and parts" do
# visit new_wholesaler_path
#
# within ".wholesaler-details" do
# @labels.each_with_index do |label, index|
# fill_in label, :with => @values[index]
# end
# select 'Credit Card', :from => 'Terms'
# end
#
# within ".user-details" do
# fill_in "Email", :with => random_email
# fill_in "Password", :with => "password"
# fill_in "Password Confirmation", :with => "password"
# end
#
# within ".billing-details" do
# @address_labels.each_with_index do |label, index|
# fill_in label, :with => @address_values[index]
# end
# select 'California', :from => 'State'
# select 'United States', :from => 'Country'
# check "Use billing address for shipping"
# end
#
#
# click_button "Create"
# assert_flash(:notice, I18n.t('admin.wholesalers.success'))
#end
#
#
#context "an existing wholesaler" do
#
# setup do
# @wholesaler = Factory.create(:wholesaler)
# end
#
# should "update wholesaler, user and addresses" do
# visit edit_wholesaler_path(@wholesaler)
# within ".wholesaler-details" do
# @labels.each_with_index do |label, index|
# fill_in label, :with => @values[index].reverse
# end
# select 'Credit Card', :from => 'Terms'
# end
# within ".billing-details" do
# @address_labels.each_with_index do |label, index|
# fill_in label, :with => @address_values[index].reverse
# end
# select 'California', :from => 'State'
# select 'United States', :from => 'Country'
# uncheck "Use billing address for shipping"
# end
# within ".shipping-details" do
# @address_labels.each_with_index do |label, index|
# fill_in label.sub('Billing', 'Shipping'), :with => @address_values[index]
# end
# select 'California', :from => 'State'
# select 'United States', :from => 'Country'
# end
# click_button "Update"
# assert_flash(:notice, "Successfully updated!")
# assert_seen "ylliB notrelliB", :within => ".rightie .adr:first"
# end


# no worky without JS :(

#should "update switch to a foreign address" do
# visit edit_wholesaler_path(@wholesaler)
#
# sleep 3
#
# within ".billing-details" do
# uncheck "Use billing address for shipping"
# end
#
# sleep 3
#
# within ".shipping-details" do
# select 'Switzerland', :from => 'Country'
#
# sleep 5
#
#
# end
#
#
#end


#end
should "be a valid wholesaler but invalid parts" do
visit new_wholesaler_path
@labels.each_with_index do |label, index|
fill_in label, :with => @values[index]
end
select 'Credit Card', :from => 'Terms'
click_button I18n.t('wholesale_apply')
assert_flash(:errors, I18n.t('wholesaler.signup_failed'))
assert_seen I18n.t("wholesaler.parts_error_message"), :within => ".wholesaler-details .errorExplanation"
end

#end
should "create wholesaler and parts" do
visit new_wholesaler_path
within ".wholesaler-details" do
@labels.each_with_index do |label, index|
fill_in label, :with => @values[index]
end
select 'Credit Card', :from => 'Terms'
end
within ".user-details" do
fill_in "Email", :with => random_email
fill_in "Password", :with => "password"
fill_in "Password Confirmation", :with => "password"
end
within ".billing-details" do
@address_labels.each_with_index do |label, index|
fill_in label, :with => @address_values[index]
end
select 'California', :from => 'State'
select 'United States', :from => 'Country'
check "Use billing address for shipping"
end
click_button I18n.t('wholesale_apply')
assert_flash(:notice, I18n.t('wholesaler.signup_success'))
end

end

0 comments on commit 9872b53

Please sign in to comment.