From 3be29fd73bf69196f9b19141a5c3f62f5fe4f941 Mon Sep 17 00:00:00 2001 From: Jamie Osler Date: Tue, 28 Oct 2014 15:21:50 +0000 Subject: [PATCH] add update_last_request_at --- lib/intercom/lib/dynamic_accessors.rb | 2 +- spec/unit/intercom/user_spec.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/intercom/lib/dynamic_accessors.rb b/lib/intercom/lib/dynamic_accessors.rb index c8cda291..1b053d2e 100644 --- a/lib/intercom/lib/dynamic_accessors.rb +++ b/lib/intercom/lib/dynamic_accessors.rb @@ -6,7 +6,7 @@ class << self def define_accessors(attribute, value, object) klass = object.class - if attribute.to_s.end_with? '_at' + if attribute.to_s.end_with?('_at') && attribute.to_s != 'update_last_request_at' define_date_based_accessors(attribute, value, klass) elsif object.flat_store_attribute?(attribute) define_flat_store_based_accessors(attribute, value, klass) diff --git a/spec/unit/intercom/user_spec.rb b/spec/unit/intercom/user_spec.rb index 5ad034c1..a46f0d91 100644 --- a/spec/unit/intercom/user_spec.rb +++ b/spec/unit/intercom/user_spec.rb @@ -77,6 +77,11 @@ user.unsubscribed_from_emails.must_equal true user.user_agent_data.must_equal "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11" end + + it 'allows update_last_request_at' do + Intercom.expects(:post).with("/users", {"user_id" => "1224242", 'update_last_request_at' => true, "custom_attributes" => {}}).returns({"user_id" => "i-1224242", "last_request_at" => 1414509439}) + Intercom::User.create(user_id:'1224242', update_last_request_at:true) + end it "allows easy setting of custom data" do now = Time.now