Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include_for_logged_out_users should still work when user excluded #293

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/intercom-rails/script_tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def initialize(options = {})
end

def valid?
return false if user_details[:excluded_user] == true
valid = user_details[:app_id].present?
unless @show_everywhere
valid = valid && (user_details[:user_id] || user_details[:email]).present?
Expand Down
9 changes: 9 additions & 0 deletions spec/auto_include_filter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,15 @@ def current_user
IntercomRails.config.include_for_logged_out_users = true
IntercomRails.config.user.exclude_if = Proc.new {|user| user.email.start_with?('ciaran')}
get :with_current_user_method
expect(response.body).to include('<script id="IntercomSettingsScriptTag">')
expect(response.body).not_to include("[email protected]")
expect(response.body).not_to include("Ciaran Lee")
end

it 'excludes tag entirely if user excluded and logged out users skipped' do
IntercomRails.config.include_for_logged_out_users = false
IntercomRails.config.user.exclude_if = Proc.new {|user| user.email.start_with?('ciaran')}
get :with_current_user_method
expect(response.body).not_to include('<script id="IntercomSettingsScriptTag">')
expect(response.body).not_to include("[email protected]")
expect(response.body).not_to include("Ciaran Lee")
Expand Down