Skip to content

Commit e15f6b9

Browse files
committed
Fix controller context
1 parent 36ea438 commit e15f6b9

File tree

7 files changed

+21
-44
lines changed

7 files changed

+21
-44
lines changed

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,6 @@ SIMPLE_USER_ACTIVATION=false
8989

9090
# Whether to show units/inspections at all
9191
HAS_ASSESSMENTS=true
92+
93+
# If you're building the Tapioca RBI files, enable this
94+
RUNNING_TAPIOCA=false

app/controllers/concerns/session_management.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def establish_user_session(user)
1414
)
1515

1616
session[:session_token] = user_session.session_token
17-
create_user_session(user)
17+
create_user_session
1818

1919
user_session
2020
end

app/helpers/concerns/controller_context.rb

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,41 @@ module ControllerContext
88
extend T::Sig
99
extend T::Helpers
1010

11-
# These methods are provided by ActionController, so we just need
12-
# to declare their signatures for Sorbet without marking them abstract
11+
abstract!
1312

14-
sig { returns(T.untyped) }
13+
# These methods are provided by ActionController/ActionView
14+
# We declare them as abstract so Sorbet knows about them
15+
# but doesn't provide implementations that would override Rails
16+
17+
sig { abstract.returns(T.untyped) }
1518
def session
1619
end
1720

18-
sig { returns(T.untyped) }
21+
sig { abstract.returns(T.untyped) }
1922
def cookies
2023
end
2124

22-
sig { returns(T.untyped) }
25+
sig { abstract.returns(T.untyped) }
2326
def params
2427
end
2528

26-
sig { returns(T.untyped) }
29+
sig { abstract.returns(T.untyped) }
2730
def request
2831
end
2932

30-
sig { returns(T.untyped) }
33+
sig { abstract.returns(T.untyped) }
3134
def flash
3235
end
3336

34-
sig { params(args: T.untyped).returns(T.untyped) }
37+
sig { abstract.params(args: T.untyped).returns(T.untyped) }
3538
def redirect_to(*args)
3639
end
3740

38-
sig { params(args: T.untyped).returns(T.untyped) }
41+
sig { abstract.params(args: T.untyped).returns(T.untyped) }
3942
def render(*args)
4043
end
4144

42-
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
45+
sig { abstract.params(args: T.untyped, block: T.untyped).returns(T.untyped) }
4346
def respond_to(*args, &block)
4447
end
4548
end

app/helpers/sessions_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ def authenticate_user(email, password)
8989
User.find_by(email: email.downcase)&.authenticate(password)
9090
end
9191

92-
sig { params(user: User).void }
93-
def create_user_session(_user)
92+
sig { void }
93+
def create_user_session
9494
remember_user
9595
end
9696

spec/controllers/application_controller_spec.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,15 +317,11 @@
317317
end
318318

319319
describe "#n_plus_one_detection" do
320-
it "is defined as a private method" do
321-
expect(controller.private_methods).to include(:n_plus_one_detection)
322-
end
323-
324320
it "wraps actions with Prosopite scanning" do
325321
expect(Prosopite).to receive(:scan)
326322
expect(Prosopite).to receive(:finish)
327323

328-
controller.send(:n_plus_one_detection) { "test" }
324+
controller.n_plus_one_detection { "test" }
329325
end
330326
end
331327
end

spec/helpers/sessions_helper_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@
172172
it "remembers the user" do
173173
expect(helper).to receive(:remember_user)
174174

175-
helper.create_user_session(user)
175+
helper.create_user_session
176176
end
177177
end
178178

spec/lib/prosopite_integration_spec.rb

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)