Skip to content
This repository was archived by the owner on Oct 27, 2021. It is now read-only.

Commit 097d63d

Browse files
committed
Fixed bug in which session object in example was not the same instance used in the controller. Closes #331.
1 parent 7f035b3 commit 097d63d

File tree

6 files changed

+24
-9
lines changed

6 files changed

+24
-9
lines changed

rspec/CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Note: we've removed the metaclass method from Object. There were some generated
55
used it, and they will now break. Just replace the metaclass call with (class << self; self; end)
66
and all will be well.
77

8+
* Fixed bug in which session object in example was not the same instance used in the controller. Closes #331.
89
* Added stub_model method which creates a real model instance with :id stubbed and data access prohibited.
910
* Applied patch from Antti Tarvainen to fix bug where heckle runs rspec runs heckle runs rspec etc. Closes #280.
1011
* Applied patch from Zach Dennis to merge :steps functionality to :steps_for. Closes #324.

rspec/lib/spec/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module VERSION
66
TINY = 3
77
RELEASE_CANDIDATE = nil
88

9-
BUILD_TIME_UTC = 20080302232403
9+
BUILD_TIME_UTC = 20080309210001
1010

1111
STRING = [MAJOR, MINOR, TINY].join('.')
1212
TAG = "REL_#{[MAJOR, MINOR, TINY, RELEASE_CANDIDATE].compact.join('_')}".upcase.gsub(/\.|-/, '_')

rspec_on_rails/lib/spec/rails/example/functional_example_group.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ class FunctionalExampleGroup < RailsExampleGroup
1111
raise "Can't determine controller class for #{@controller_class_name}" if @controller_class.nil?
1212

1313
@controller = @controller_class.new
14-
1514
@request = ActionController::TestRequest.new
1615
@response = ActionController::TestResponse.new
16+
@response.session = @request.session
1717
end
1818

1919
def params
@@ -25,7 +25,7 @@ def flash
2525
end
2626

2727
def session
28-
request.session
28+
@response.session
2929
end
3030

3131
# :call-seq:

rspec_on_rails/lib/spec/rails/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Spec
22
module Rails
33
module VERSION #:nodoc:
4-
BUILD_TIME_UTC = 20080302232403
4+
BUILD_TIME_UTC = 20080309210001
55
end
66
end
77
end

rspec_on_rails/spec/rails/example/controller_spec_spec.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
end
6868

6969
it "should provide access to flash" do
70-
get 'action_with_template'
70+
get 'action_which_sets_flash'
7171
flash[:flash_key].should == "flash value"
7272
end
7373

@@ -82,8 +82,10 @@
8282
end
8383

8484
it "should provide access to session" do
85-
get 'action_with_template'
86-
session[:session_key].should == "session value"
85+
session[:session_key] = "session value"
86+
lambda do
87+
get 'action_which_gets_session', :expected => "session value"
88+
end.should_not raise_error
8789
end
8890

8991
it "should support custom routes" do

rspec_on_rails/spec_resources/controllers/controller_spec_controller.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,23 @@ def some_action
1010
end
1111

1212
def action_with_template
13-
session[:session_key] = "session value"
14-
flash[:flash_key] = "flash value"
1513
render :template => "controller_spec/action_with_template"
1614
end
1715

16+
def action_which_sets_flash
17+
flash[:flash_key] = "flash value"
18+
render :text => ""
19+
end
20+
21+
def action_which_gets_session
22+
raise "expected #{params[:session_key].inspect}\ngot #{session[:session_key].inspect}" unless (session[:session_key] == params[:expected])
23+
render :text => ""
24+
end
25+
26+
def action_which_sets_session
27+
session[:session_key] = "session value"
28+
end
29+
1830
def action_with_partial
1931
render :partial => "controller_spec/partial"
2032
end

0 commit comments

Comments
 (0)