From 9becd8eb73bd94b920fe87a445a7e88525a327f3 Mon Sep 17 00:00:00 2001 From: Dzmitry Kremez Date: Tue, 13 Feb 2024 09:04:35 +0000 Subject: [PATCH] Provide installation type as settings attribute (#350) * Provide installation type as settings attribute * Update CI ruby version to fix CI build * Bump gem version number to 1.0.0 as we dropped active record 3.x support --------- Co-authored-by: Dzmitry Kremez --- .circleci/config.yml | 2 +- intercom-rails.gemspec | 11 ++++++----- lib/intercom-rails/script_tag.rb | 5 ++--- lib/intercom-rails/version.rb | 2 +- spec/script_tag_helper_spec.rb | 2 +- spec/script_tag_spec.rb | 9 ++++++++- 6 files changed, 19 insertions(+), 12 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 348cea4..465eccf 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,7 +2,7 @@ version: 2 jobs: build: docker: - - image: circleci/ruby:2.5.7 + - image: cimg/ruby:2.7 working_directory: ~/intercom-rails diff --git a/intercom-rails.gemspec b/intercom-rails.gemspec index 44d9c83..03b9633 100644 --- a/intercom-rails.gemspec +++ b/intercom-rails.gemspec @@ -18,14 +18,15 @@ Gem::Specification.new do |s| s.files = Dir["{app,config,db,lib}/**/*"] + ["Rakefile", "README.md"] s.test_files = Dir["test/**/*"] - s.add_dependency 'activesupport', '>3.0' + s.add_dependency 'activesupport', '>4.0' s.add_development_dependency 'rake' - s.add_development_dependency 'actionpack', '>3.2.12' - s.add_development_dependency 'rspec', '~> 3.1' - s.add_development_dependency 'rspec-rails', '~> 3.1' + s.add_development_dependency 'actionpack', '>5.0' + s.add_development_dependency 'rspec', '~> 3.13' + s.add_development_dependency 'rspec-rails', '~> 5.0' s.add_development_dependency 'pry' - s.add_development_dependency 'sinatra', '~> 1.4.5' + s.add_development_dependency 'sinatra', '~> 2.0' s.add_development_dependency 'thin', '~> 1.7.0' + s.add_development_dependency 'bigdecimal', '1.3.5' s.add_development_dependency 'tzinfo' s.add_development_dependency 'gem-release' end diff --git a/lib/intercom-rails/script_tag.rb b/lib/intercom-rails/script_tag.rb index 319f471..db439c9 100644 --- a/lib/intercom-rails/script_tag.rb +++ b/lib/intercom-rails/script_tag.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true -require 'active_support/json' -require 'active_support/core_ext/hash/indifferent_access' -require 'active_support/core_ext/string/output_safety' +require 'active_support/all' require 'action_view' module IntercomRails @@ -72,6 +70,7 @@ def intercom_settings hsh[:company] = company_details if company_details.present? hsh[:hide_default_launcher] = Config.hide_default_launcher if Config.hide_default_launcher hsh[:api_base] = Config.api_base if Config.api_base + hsh[:installation_type] = 'rails' hsh end diff --git a/lib/intercom-rails/version.rb b/lib/intercom-rails/version.rb index e2aef2d..8c2b46c 100644 --- a/lib/intercom-rails/version.rb +++ b/lib/intercom-rails/version.rb @@ -1,3 +1,3 @@ module IntercomRails - VERSION = "0.4.2" + VERSION = "1.0.0" end diff --git a/spec/script_tag_helper_spec.rb b/spec/script_tag_helper_spec.rb index 8fab37a..4c2c780 100644 --- a/spec/script_tag_helper_spec.rb +++ b/spec/script_tag_helper_spec.rb @@ -35,7 +35,7 @@ :email => 'marco@intercom.io', :user_id => 'marco', }) - expect(script_tag.csp_sha256).to eq("'sha256-qLRbekKD6dEDMyLKPNFYpokzwYCz+WeNPqJE603mT24='") + expect(script_tag.csp_sha256).to eq("'sha256-lOGcYryJDhf1KCboXuy8wxCxIGAT16HDiUQNRhluxRQ='") end it 'inserts a valid nonce if present' do diff --git a/spec/script_tag_spec.rb b/spec/script_tag_spec.rb index 705fe24..53bd084 100644 --- a/spec/script_tag_spec.rb +++ b/spec/script_tag_spec.rb @@ -37,6 +37,13 @@ end end + context 'integration type' do + it 'should be rails' do + script_tag = ScriptTag.new() + expect(script_tag.intercom_settings[:installation_type]).to eq('rails') + end + end + it 'strips out nil entries for standard attributes' do %w(name email user_id).each do |standard_attribute| with_value = ScriptTag.new(:user_details => {standard_attribute => 'value'}) @@ -199,7 +206,7 @@ def sha256_hmac(secret, input) :email => 'marco@intercom.io', :user_id => 'marco', }) - expect(script_tag.csp_sha256).to eq("'sha256-qLRbekKD6dEDMyLKPNFYpokzwYCz+WeNPqJE603mT24='") + expect(script_tag.csp_sha256).to eq("'sha256-lOGcYryJDhf1KCboXuy8wxCxIGAT16HDiUQNRhluxRQ='") end it 'inserts a valid nonce if present' do