Skip to content

Instantly share code, notes, and snippets.

@gmgent
Created March 18, 2011 00:26
Show Gist options
  • Save gmgent/875413 to your computer and use it in GitHub Desktop.
Save gmgent/875413 to your computer and use it in GitHub Desktop.
require File.dirname(__FILE__) + '/../test_helper'
require 'xmlsimple'
class ReportMethodsTest < ActiveSupport::TestCase
fixtures :roles, :partners
def setup
@u_admin_gmg = new_test_user(:role => roles(:admin), :partner => partners(:gmg))
@u_admin = new_test_user(:role => roles(:admin), :partner => partners(:other))
@runcode = Time.now.strftime("%Y%m%d")
@inbound = Inbound.create(:account_id => "999",
:file_name => "test.csv",
:run_code => @runcode)
end
def test_gmg_user_xml_for_sale
sale = fake_sale(:inbound => @inbound, :serial_number => 99999,
:item_date => Date.today.strftime("%Y-%m-%d"),
:amount => 99, :rec_type => "Sales" )
testing = XmlSimple.xml_in(@u_admin_gmg.sales_display_xml)
assert testing["set"].first["value"] == "99"
end
def test_gmg_user_xml_for_non_sale
sale = fake_sale(:inbound => @inbound, :serial_number => 99999,
:item_date => Date.today.strftime("%Y-%m-%d"),
:amount => 99, :rec_type => "Promo" )
testing = XmlSimple.xml_in(@u_admin_gmg.sales_display_xml)
assert_nil testing["set"]
end
def test_partner_user_xml_for_sale
@partner_account = new_test_account(:partner => partners(:other))
@partner_inbound = Inbound.create(:account => @partner_account, :file_name => "test.csv", :run_code => @runcode)
sale = fake_sale(:inbound => @partner_inbound, :serial_number => 99999,
:item_date => Date.today.strftime("%Y-%m-%d"),
:amount => 99, :rec_type => "Sales" )
testing = XmlSimple.xml_in(@u_admin.sales_display_xml)
assert testing["set"].first["value"] == "99"
end
def test_partner_user_xml_for_non_sale
@partner_account = new_test_account(:partner => partners(:other))
@partner_inbound = Inbound.create(:account => @partner_account, :file_name => "test.csv", :run_code => @runcode)
sale = fake_sale(:inbound => @partner_inbound, :serial_number => 99999,
:item_date => Date.today.strftime("%Y-%m-%d"),
:amount => 99, :rec_type => "Promo" )
testing = XmlSimple.xml_in(@u_admin.sales_display_xml)
assert_nil testing["set"]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment