Skip to content

Commit

Permalink
Provide installation type as settings attribute (#350)
Browse files Browse the repository at this point in the history
* 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 <dzmitry.kremez@intercom.io>
  • Loading branch information
dkremez and Dzmitry Kremez authored Feb 13, 2024
1 parent 0e654be commit 9becd8e
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2
jobs:
build:
docker:
- image: circleci/ruby:2.5.7
- image: cimg/ruby:2.7

working_directory: ~/intercom-rails

Expand Down
11 changes: 6 additions & 5 deletions intercom-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 2 additions & 3 deletions lib/intercom-rails/script_tag.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/intercom-rails/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module IntercomRails
VERSION = "0.4.2"
VERSION = "1.0.0"
end
2 changes: 1 addition & 1 deletion spec/script_tag_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion spec/script_tag_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'})
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9becd8e

Please sign in to comment.