Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 01f380b

Browse files
committedJun 8, 2015
Move login_required_redirection_url() into rails_helper.rb
1 parent f597b3b commit 01f380b

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed
 

‎spec/rails_helper.rb

+22
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,28 @@
8282
require Rails.root.join('config', 'initializers', 'active_record_observer_hooks')
8383
# see comments in this file for more info
8484

85+
# Common login-testing strategies in the specs
86+
#
87+
if Squash::Configuration.authentication.strategy == 'google'
88+
RSpec.shared_context "setup for required logged-in user" do
89+
unless Squash::Configuration.authentication.strategy == 'google'
90+
def login_required_redirection_url(*args)
91+
login_url(*args)
92+
end
93+
94+
else
95+
before :each do
96+
allow(SecureRandom).to receive(:hex).and_return('1234')
97+
end
98+
99+
def login_required_redirection_url(*args)
100+
controller.instance_eval { google_authentication_uri }
101+
end
102+
end
103+
104+
end
105+
end
106+
85107
# Logs a user in for spec purposes.
86108
#
87109
# @params [User] user A user.

‎spec/spec_helper.rb

-23
Original file line numberDiff line numberDiff line change
@@ -24,29 +24,6 @@
2424
# individual file that may not need all of that loaded. Instead, consider making
2525
# a separate helper file that requires the additional dependencies and performs
2626
# the additional setup, and require it from the spec files that actually need it.
27-
# Common login-testing strategies in the specs
28-
#
29-
# @param [*args] Args to pass to #get
30-
if Squash::Configuration.authentication.strategy == 'google'
31-
RSpec.shared_context "setup for required logged-in user" do
32-
unless Squash::Configuration.authentication.strategy == 'google'
33-
def login_required_redirection_url(*args)
34-
login_url(*args)
35-
end
36-
37-
else
38-
before :each do
39-
allow(SecureRandom).to receive(:hex).and_return('1234')
40-
end
41-
42-
def login_required_redirection_url(*args)
43-
controller.instance_eval { google_authentication_uri }
44-
end
45-
end
46-
47-
end
48-
end
49-
5027
#
5128
# The `.rspec` file also contains a few flags that are not defaults but that
5229
# users commonly want.

0 commit comments

Comments
 (0)
Please sign in to comment.