test/salesforce/base_test.rb in activeforce-1.7.1 vs test/salesforce/base_test.rb in activeforce-1.8.0
- old
+ new
@@ -256,11 +256,11 @@
end
def test_find_all__with_conditions
setup_columns_for_original_table
Salesforce.connection.expects(:soql).with("SELECT Col1,Col2__c FROM OriginalTable WHERE Col2__c >= 2011-11-11").returns([ { "Col2__c" => 'col21'}, { "Col2__c" => 'col22'}])
- results = Salesforce::OriginalTable.find(:all, :conditions => ":col2 >= :date", :date => Date.parse("11/11/2011"))
+ results = Salesforce::OriginalTable.find(:all, :conditions => ":col2 >= :date", :date => Date.parse("2011-11-11"))
assert_equal 2, results.size
assert_equal "col21", results.first.col2
assert_equal "col22", results.last.col2
end
@@ -280,14 +280,14 @@
assert_equal "SELECT ZCol4__c,Col2__c FROM OriginalTable", Salesforce::OriginalTable.query_string({:select => [ :z_col4, :col2 ]})
assert_equal "SELECT ACol5__c FROM OriginalTable WHERE Col1 > Col2__c", Salesforce::OriginalTable.query_string(:select => :a_col5, :conditions => ":col1 > :col2")
assert_equal "SELECT ACol5__c FROM OriginalTable WHERE Col1 > Col2__c", Salesforce::OriginalTable.query_string(:select => :a_col5, :conditions => ":col1 > :col2")
assert_equal "SELECT ACol5__c FROM OriginalTable WHERE Col1 > 2011-08-01", Salesforce::OriginalTable.query_string(:select => :a_col5, :conditions => ":col1 > :date",
- :date => Date.parse('08/01/2011') )
+ :date => Date.parse('2011-08-01') )
assert_equal "SELECT ACol5__c FROM OriginalTable WHERE Col1 > 2011-08-01 AND ACol5__c = 2011-08-01T09:30:00-07:00",
Salesforce::OriginalTable.query_string(:select => :a_col5,
- :conditions => ":col1 > :date AND :a_col5 = :time", :date => Date.parse('08/01/2011'), :time => Time.zone.parse("08/01/2011 09:30 AM"))
+ :conditions => ":col1 > :date AND :a_col5 = :time", :date => Date.parse('2011-08-01'), :time => Time.zone.parse("2011-08-01 09:30 AM"))
assert_equal "SELECT ACol5__c FROM OriginalTable WHERE Col1 = TRUE AND Col2__c = FALSE AND Col3__c = NULL",
Salesforce::OriginalTable.query_string(:select => :a_col5,
:conditions => ":col1 = :true AND :col2 = :false AND :col3 = :nil", :true => true, :false => false, :nil => nil)
@@ -301,11 +301,11 @@
Salesforce::OriginalTable.query_string(:select => :a_col5, :conditions => ":col1 = :string",
:string => 'string' , :order => ":col1 ASC, :col3 DESC")
assert_equal "SELECT ACol5__c FROM OriginalTable WHERE Col1 = 'string' GROUP BY Col2__c HAVING Col3__c > 2009-08-01 ORDER BY Col1 ASC, Col3__c DESC",
Salesforce::OriginalTable.query_string(:select => :a_col5, :conditions => ":col1 = :string", :group_by => :col2, :having => ":col3 > :date",
- :string => 'string', :date => Date.parse('08/01/2009'), :order => ":col1 ASC, :col3 DESC")
+ :string => 'string', :date => Date.parse('2009-08-01'), :order => ":col1 ASC, :col3 DESC")
assert_raises Salesforce::ColumnNotFound do
Salesforce::OriginalTable.query_string({:select => [ :col4 ]})
@@ -347,12 +347,13 @@
end
end
def test_find_by_column
setup_columns_for_original_table
- Salesforce.connection.expects(:soql).with("SELECT Col1,Col2__c FROM OriginalTable WHERE Col2__c='value'").returns([ { "Col1" => 'col11', "Col2__c" => 'col21'}, { "Col1" => 'col21', "Col2__c" => 'col22'} ])
- results = Salesforce::OriginalTable.find_by_column(Salesforce::OriginalTable.columns.all.last, "value")
+ col = Salesforce::OriginalTable.columns.all.last
+ Salesforce.connection.expects(:soql).with("SELECT Col1,Col2__c FROM OriginalTable WHERE #{col.original_name}='value'").returns([ { "Col1" => 'col11', "Col2__c" => 'col21'}, { "Col1" => 'col21', "Col2__c" => 'col22'} ])
+ results = Salesforce::OriginalTable.find_by_column(col, "value")
assert_equal 2, results.size
assert_equal "col11", results.first.col1
assert_equal "col21", results.first.col2
assert_equal "col21", results.last.col1
assert_equal "col22", results.last.col2
@@ -382,11 +383,11 @@
raise Salesforce::InvalidRequest.new({ 'errorCode' => 'INVALID_FIELD'}, '/foo')
end
end
end
- def test_with_invalid_column_handling__throws_invalid_fields_error__more_than_once
+ def test_with_invalid_column_handling__throws_runtime_error__more_than_once
error = RuntimeError.new
Salesforce::OriginalTable.expects(:clear_cached_columns!).never
assert_raises error.class do
Salesforce::OriginalTable.with_invalid_column_handling do
@@ -435,6 +436,6 @@
assert_equal columns, Salesforce::CustomTable.columns
end
end
-
\ No newline at end of file
+