Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require File.dirname(__FILE__) + '/../test_helper'
- class DataEntryTest < ActionController::IntegrationTest
- fixtures :all
- def test_check_valid_data_entry_display
- log_in_user
- get '/data_entry'
- assert_tag 'tbody',:attributes => {:class => 'editable body-1'},:child => {:tag => 'tr',:child => {:tag => 'td',:child => {:tag => 'input',:attributes => {:id => "category_orders_2010-Feb_2_5",:value => nil}}}}
- post '/data_entry',{:category_orders => {"2010-Feb" => {"2" => {"5" => '1',"8" => '2',"9" => '3',"12" => '0',"16" => '251'}}},:commit => 'Save', "period"=>"2010-Feb"}
- post '/data_entry/update_units', {:units => 'tonne'}
- sp = Supplier.find(:first)
- assert_equal 'tonne',sp.units
- assert_response :redirect
- assert_redirected_to :action => :index
- get '/data_entry'
- assert_tag 'tbody',:attributes => {:class => 'editable body-1'},:child => {:tag => 'tr',:child => {:tag => 'td',:child => {:tag => 'input',:attributes => {:id => "category_orders_2010-Feb_2_5",:value => nil}}}}
- post '/data_entry',{:category_orders => {"2010-Feb" => {"2" => {"5" => '1',"8" => '2',"9" => '3',"12" => '0',"16" => '251'}}},:commit => 'Save', "period"=>"2010-Feb"}
- assert_response :success
- po = PurchaseOrder.find_by_category_id_and_profile_id('2','5')
- assert_equal "1.0",po.volume.to_s
- get '/data_entry'
- assert_response :success
- assert_tag 'tbody',:attributes => {:class => 'editable body-1'},:child => {:tag => 'tr',:child => {:tag => 'td',:child => {:tag => 'input',:attributes => {:id => "category_orders_2010-Feb_2_5",:value => "1.0"}}}}
- assert_tag 'tbody',:attributes => {:class => 'editable body-1'},:child => {:tag => 'tr',:child => {:tag => 'td',:child => {:tag => 'input',:attributes => {:id => "category_orders_2010-Feb_2_12",:value => nil}}}}
- assert_tag 'tbody',:attributes => {:class => 'editable body-1'},:child => {:tag => 'tr',:child => {:tag => 'td',:child => {:tag => 'input',:attributes => {:id => "category_orders_2010-Feb_2_16",:value => "251.0"}}}}
- assert_tag 'p',:attributes => {:id => 'warning-para',:class => 'warning'},:content => "Data for 2010-Feb, alaska pollock - eastern bering sea (usa; tm; aspa; msc-c) for category APMEA - are you sure 251.0 is entered in metric tonnes?"
- end
- private
- #login user and check redirect to the traffic_lights ('/').
- def log_in_user
- user = users(:clerk_1)
- post '/login/login', :user => {:login => user.email, :password => 'secretive' }
- assert_response :redirect
- assert_redirected_to '/'
- # follow_redirect!
- # assert_tag 'h2',:content => 'Traffic lights'
- @request.session = {:user_id => user.id}
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement