Skip to content

Commit 71c7efa

Browse files
committed
update test dependencies
1 parent 35b5f94 commit 71c7efa

File tree

5 files changed

+97
-92
lines changed

5 files changed

+97
-92
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: 2
22
jobs:
33
build:
44
docker:
5-
- image: circleci/ruby:2.5.7
5+
- image: circleci/ruby:2.6.6
66

77
working_directory: ~/intercom-rails
88

intercom-rails.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
2424
s.add_development_dependency 'rspec', '~> 3.1'
2525
s.add_development_dependency 'rspec-rails', '~> 3.1'
2626
s.add_development_dependency 'pry'
27-
s.add_development_dependency 'sinatra', '~> 1.4.5'
27+
s.add_development_dependency 'sinatra', '~> 2.0.0'
2828
s.add_development_dependency 'thin', '~> 1.7.0'
2929
s.add_development_dependency 'tzinfo'
3030
s.add_development_dependency 'gem-release'

spec/action_controller_spec_helper.rb

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ def self.env
1111
end
1212
end
1313

14-
TestRoutes = ActionDispatch::Routing::RouteSet.new
15-
TestRoutes.draw do
16-
get ':controller(/:action)'
17-
end
18-
1914
module IntercomRails
2015
class Application < Rails::Application
2116
config.secret_key_base = 'secret_key_base'
@@ -34,7 +29,18 @@ class ActionController::Base
3429
else
3530
after_filter :intercom_rails_auto_include
3631
end
32+
end
33+
34+
require 'test_controller'
35+
36+
TestRoutes = ActionDispatch::Routing::RouteSet.new
37+
TestRoutes.draw do
38+
TestController.public_instance_methods.each do |method|
39+
get "test/#{method}", to: "test##{method}"
40+
end
41+
end
3742

43+
class ActionController::Base
3844
include TestRoutes.url_helpers
3945
include TestRoutes.mounted_helpers
4046
end

spec/auto_include_filter_spec.rb

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,5 @@
11
require 'action_controller_spec_helper'
22

3-
class TestController < ActionController::Base
4-
if respond_to? :skip_after_action
5-
skip_after_action :intercom_rails_auto_include, :only => :with_user_instance_variable_after_filter_skipped
6-
else
7-
skip_after_filter :intercom_rails_auto_include, :only => :with_user_instance_variable_after_filter_skipped
8-
end
9-
10-
def without_user
11-
render_content("<body>Hello world</body>")
12-
end
13-
14-
def with_user_instance_variable
15-
@user = dummy_user
16-
render_content("<body>Hello world</body>")
17-
end
18-
19-
def with_user_instance_variable_no_body_tag
20-
render_content("Hello world")
21-
end
22-
23-
def with_user_instance_variable_after_filter_skipped
24-
with_user_instance_variable
25-
end
26-
27-
def with_user_and_app_instance_variables
28-
@user = dummy_user
29-
@app = dummy_company
30-
render_content("<body>Hello world</body>")
31-
end
32-
33-
def with_user_instance_variable_and_custom_data
34-
@user = dummy_user
35-
intercom_custom_data.user['testing_stuff'] = true
36-
render_content("<body>Hello world</body>")
37-
end
38-
39-
def with_unusable_user_instance_variable
40-
@user = Object.new
41-
render_content("<body>Hello world</body>")
42-
end
43-
44-
def with_mongo_like_user
45-
@user = Struct.new(:id).new.tap do |user|
46-
user.id = DummyBSONId.new('deadbeaf1234mongo')
47-
end
48-
render_content("<body>Hello world</body>")
49-
end
50-
51-
def with_numeric_user_id
52-
@user = Struct.new(:id).new.tap do |user|
53-
user.id = 123
54-
end
55-
render_content("<body>Hello world</body>")
56-
end
57-
58-
def with_current_user_method
59-
render_content("<body>Hello world</body>")
60-
end
61-
62-
def with_admin_instance_variable
63-
@admin = dummy_user(:email => '[email protected]', :name => 'Eoghan McCabe')
64-
render_content("<body>Hello world</body>")
65-
end
66-
67-
def with_some_tricky_string
68-
@user = dummy_user(:email => "\\\"foo\"")
69-
render_content("<body>Hello world</body>")
70-
end
71-
72-
private
73-
74-
def render_content(body)
75-
if Rails::VERSION::MAJOR >= 5
76-
render :body => body, :content_type => 'text/html'
77-
else
78-
render :text => body, :content_type => 'text/html'
79-
end
80-
end
81-
82-
def current_user
83-
raise NameError if params[:action] != 'with_current_user_method'
84-
dummy_user(:email => '[email protected]', :name => 'Ciaran Lee')
85-
end
86-
end
87-
883
describe TestController, type: :controller do
894
it 'has no intercom script if no user present' do
905
get :without_user

spec/test_controller.rb

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
class TestController < ActionController::Base
2+
if respond_to? :skip_after_action
3+
skip_after_action :intercom_rails_auto_include, :only => :with_user_instance_variable_after_filter_skipped
4+
else
5+
skip_after_filter :intercom_rails_auto_include, :only => :with_user_instance_variable_after_filter_skipped
6+
end
7+
8+
def without_user
9+
render_content("<body>Hello world</body>")
10+
end
11+
12+
def with_user_instance_variable
13+
@user = dummy_user
14+
render_content("<body>Hello world</body>")
15+
end
16+
17+
def with_user_instance_variable_no_body_tag
18+
render_content("Hello world")
19+
end
20+
21+
def with_user_instance_variable_after_filter_skipped
22+
with_user_instance_variable
23+
end
24+
25+
def with_user_and_app_instance_variables
26+
@user = dummy_user
27+
@app = dummy_company
28+
render_content("<body>Hello world</body>")
29+
end
30+
31+
def with_user_instance_variable_and_custom_data
32+
@user = dummy_user
33+
intercom_custom_data.user['testing_stuff'] = true
34+
render_content("<body>Hello world</body>")
35+
end
36+
37+
def with_unusable_user_instance_variable
38+
@user = Object.new
39+
render_content("<body>Hello world</body>")
40+
end
41+
42+
def with_mongo_like_user
43+
@user = Struct.new(:id).new.tap do |user|
44+
user.id = DummyBSONId.new('deadbeaf1234mongo')
45+
end
46+
render_content("<body>Hello world</body>")
47+
end
48+
49+
def with_numeric_user_id
50+
@user = Struct.new(:id).new.tap do |user|
51+
user.id = 123
52+
end
53+
render_content("<body>Hello world</body>")
54+
end
55+
56+
def with_current_user_method
57+
render_content("<body>Hello world</body>")
58+
end
59+
60+
def with_admin_instance_variable
61+
@admin = dummy_user(:email => '[email protected]', :name => 'Eoghan McCabe')
62+
render_content("<body>Hello world</body>")
63+
end
64+
65+
def with_some_tricky_string
66+
@user = dummy_user(:email => "\\\"foo\"")
67+
render_content("<body>Hello world</body>")
68+
end
69+
70+
private
71+
72+
def render_content(body)
73+
if Rails::VERSION::MAJOR >= 5
74+
render :body => body, :content_type => 'text/html'
75+
else
76+
render :text => body, :content_type => 'text/html'
77+
end
78+
end
79+
80+
def current_user
81+
raise NameError if params[:action] != 'with_current_user_method'
82+
dummy_user(:email => '[email protected]', :name => 'Ciaran Lee')
83+
end
84+
end

0 commit comments

Comments
 (0)