Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adds integration tests for historical transaction collection

  • Loading branch information...
commit b703fde4a47cd958f02582dd597a9f6873deeec9 1 parent e206e97
@gtrogers gtrogers authored
View
42 spec/fixtures/weekly_transaction_response__2012-12-09.json
@@ -0,0 +1,42 @@
+{"kind":"analytics#gaData", "id":"https://www.googleapis.com/analytics/v3/data/ga?ids=ga:61976178&dimensions=ga:week,ga:eventCategory,ga:eventLabel&metrics=ga:totalEvents&filters=ga:eventCategory%3D%3DMS_transaction&start-date=2012-12-09&end-date=2012-12-15", "query":{
+ "start-date":"2012-12-09",
+ "end-date":"2012-12-15",
+ "ids":"ga:61976178",
+ "dimensions":"ga:week,ga:eventCategory,ga:eventLabel",
+ "metrics":["ga:totalEvents"],
+ "filters":"ga:eventCategory==MS_transaction",
+ "start-index":1,
+ "max-results":1000
+}, "itemsPerPage":1000, "totalResults":1, "selfLink":"https://www.googleapis.com/analytics/v3/data/ga?ids=ga:61976178&dimensions=ga:week,ga:eventCategory,ga:eventLabel&metrics=ga:totalEvents&filters=ga:eventCategory%3D%3DMS_transaction&start-date=2012-12-09&end-date=2012-12-15", "profileInfo":{
+ "profileId":"61976178",
+ "accountId":"33336744",
+ "webPropertyId":"UA-33336744-1",
+ "internalWebPropertyId":"60590321",
+ "profileName":"exit_tracking",
+ "tableId":"ga:61976178"
+}, "containsSampledData":false, "columnHeaders":[
+ {
+ "name":"ga:week",
+ "columnType":"DIMENSION",
+ "dataType":"STRING"
+ },
+ {
+ "name":"ga:eventCategory",
+ "columnType":"DIMENSION",
+ "dataType":"STRING"
+ },
+ {
+ "name":"ga:eventLabel",
+ "columnType":"DIMENSION",
+ "dataType":"STRING"
+ },
+ {
+ "name":"ga:totalEvents",
+ "columnType":"METRIC",
+ "dataType":"INTEGER"
+ }
+], "totalsForAllResults":{
+ "ga:totalEvents":"1246465"
+}, "rows":[
+ ["50", "MS_transaction", "Success", "1246465"]
+]}
View
42 spec/fixtures/weekly_transaction_response__2012-12-16.json
@@ -0,0 +1,42 @@
+{"kind":"analytics#gaData", "id":"https://www.googleapis.com/analytics/v3/data/ga?ids=ga:61976178&dimensions=ga:week,ga:eventCategory,ga:eventLabel&metrics=ga:totalEvents&filters=ga:eventCategory%3D%3DMS_transaction&start-date=2012-12-16&end-date=2012-12-22", "query":{
+ "start-date":"2012-12-16",
+ "end-date":"2012-12-22",
+ "ids":"ga:61976178",
+ "dimensions":"ga:week,ga:eventCategory,ga:eventLabel",
+ "metrics":["ga:totalEvents"],
+ "filters":"ga:eventCategory==MS_transaction",
+ "start-index":1,
+ "max-results":1000
+}, "itemsPerPage":1000, "totalResults":1, "selfLink":"https://www.googleapis.com/analytics/v3/data/ga?ids=ga:61976178&dimensions=ga:week,ga:eventCategory,ga:eventLabel&metrics=ga:totalEvents&filters=ga:eventCategory%3D%3DMS_transaction&start-date=2012-12-16&end-date=2012-12-22", "profileInfo":{
+ "profileId":"61976178",
+ "accountId":"33336744",
+ "webPropertyId":"UA-33336744-1",
+ "internalWebPropertyId":"60590321",
+ "profileName":"exit_tracking",
+ "tableId":"ga:61976178"
+}, "containsSampledData":false, "columnHeaders":[
+ {
+ "name":"ga:week",
+ "columnType":"DIMENSION",
+ "dataType":"STRING"
+ },
+ {
+ "name":"ga:eventCategory",
+ "columnType":"DIMENSION",
+ "dataType":"STRING"
+ },
+ {
+ "name":"ga:eventLabel",
+ "columnType":"DIMENSION",
+ "dataType":"STRING"
+ },
+ {
+ "name":"ga:totalEvents",
+ "columnType":"METRIC",
+ "dataType":"INTEGER"
+ }
+], "totalsForAllResults":{
+ "ga:totalEvents":"1104371"
+}, "rows":[
+ ["51", "MS_transaction", "Success", "1104371"]
+]}
View
42 spec/fixtures/weekly_transaction_response__2012-12-23.json
@@ -0,0 +1,42 @@
+{"kind":"analytics#gaData", "id":"https://www.googleapis.com/analytics/v3/data/ga?ids=ga:61976178&dimensions=ga:week,ga:eventCategory,ga:eventLabel&metrics=ga:totalEvents&filters=ga:eventCategory%3D%3DMS_transaction&start-date=2012-12-23&end-date=2012-12-29", "query":{
+ "start-date":"2012-12-23",
+ "end-date":"2012-12-29",
+ "ids":"ga:61976178",
+ "dimensions":"ga:week,ga:eventCategory,ga:eventLabel",
+ "metrics":["ga:totalEvents"],
+ "filters":"ga:eventCategory==MS_transaction",
+ "start-index":1,
+ "max-results":1000
+}, "itemsPerPage":1000, "totalResults":1, "selfLink":"https://www.googleapis.com/analytics/v3/data/ga?ids=ga:61976178&dimensions=ga:week,ga:eventCategory,ga:eventLabel&metrics=ga:totalEvents&filters=ga:eventCategory%3D%3DMS_transaction&start-date=2012-12-23&end-date=2012-12-29", "profileInfo":{
+ "profileId":"61976178",
+ "accountId":"33336744",
+ "webPropertyId":"UA-33336744-1",
+ "internalWebPropertyId":"60590321",
+ "profileName":"exit_tracking",
+ "tableId":"ga:61976178"
+}, "containsSampledData":false, "columnHeaders":[
+ {
+ "name":"ga:week",
+ "columnType":"DIMENSION",
+ "dataType":"STRING"
+ },
+ {
+ "name":"ga:eventCategory",
+ "columnType":"DIMENSION",
+ "dataType":"STRING"
+ },
+ {
+ "name":"ga:eventLabel",
+ "columnType":"DIMENSION",
+ "dataType":"STRING"
+ },
+ {
+ "name":"ga:totalEvents",
+ "columnType":"METRIC",
+ "dataType":"INTEGER"
+ }
+], "totalsForAllResults":{
+ "ga:totalEvents":"837826"
+}, "rows":[
+ ["52", "MS_transaction", "Success", "837826"]
+]}
View
21 spec/integration/weekly_transaction_spec.rb
@@ -33,4 +33,25 @@
"format" => "transaction"
)
end
+
+ it "should query google analytics for historical queries" do
+ @ga_request.register("2012-12-23", "2012-12-29",
+ "weekly_transaction_response__2012-12-23.json")
+ @ga_request.register("2012-12-16", "2012-12-22",
+ "weekly_transaction_response__2012-12-16.json")
+ @ga_request.register("2012-12-09", "2012-12-15",
+ "weekly_transaction_response__2012-12-09.json")
+
+ Timecop.travel(DateTime.parse("2012-12-31")) do
+ configs = GoogleAnalytics::Config::WeeklyTransaction.all_within(Date.new(2012,12,9),Date.today)
+ collector = GoogleAnalytics::Collector.new(nil, configs)
+
+ response = collector.collect_as_json
+ response.should have(3).items
+
+ response.first.should be_for_time_period(Date.new(2012,12,9), Date.new(2012,12,16))
+ response[1].should be_for_time_period(Date.new(2012,12,16), Date.new(2012,12,23))
+ response[2].should be_for_time_period(Date.new(2012,12,23), Date.new(2012,12,30))
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.