# Issues with Tests

**URL:** <https://www.ruby-forum.com/t/issues-with-tests/89258>\
**Category:** Rails\
**Created:** [March 19, 2007, 1:12am UTC](https://www.ruby-forum.com/t/issues-with-tests/89258 "2007-03-19T01:12:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![keynan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/8dc957/32.png) [@keynan](https://www.ruby-forum.com/u/keynan)\
**Post date:** [March 19, 2007, 1:12am UTC](https://www.ruby-forum.com/t/issues-with-tests/89258/1 "2007-03-19T01:12:07Z")

</div>

Test Code:

def setup  
@controller = SettingsController.new  
@request = ActionController::TestRequest.new  
@response = ActionController::TestResponse.new

@request.session[:user\_id] = User.find(1)  
@request.session[:time\_of\_last\_action] = (Time.now - 30\*60)  
end

def test\_turn\_wysiwyg\_off  
post ‘index’, {:settings =\> {:wysiwyg =\> 0}}  
assert\_equal(nil, session[:user\_id].settings)  
assert\_equal(false, session[:user\_id].settings.wysiwyg,  
‘Session was not updated’)  
assert\_equal(false, UserSetting.find(1).wysiwyg, ‘Database was not  
updated’)

assert\_equal ‘Your settings have been successfully updated’,  
flash[:notice]  
end

=========================================================================

Action Code:

def index  
if request.post?  
if (session[:user\_id].settings.update\_attributes(params[:settings]))  
if(session[:user\_id].settings.save)  
flash[:notice] = ‘Your settings have been successfully updated’  
else  
flash[:notice] = ‘Your settings could not be updated’  
end  
end  
end  
@settings = session[:user\_id].settings  
end

============================================================================

The action passes when tested manually.  
It appears as though I don’t have access to any changes to the session

Does any one know how to make the magic happen?

---

<div class="post-metadata">

**Author:** ![keynan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/8dc957/32.png) [@keynan](https://www.ruby-forum.com/u/keynan)\
**Post date:** [March 19, 2007, 3:04am UTC](https://www.ruby-forum.com/t/issues-with-tests/89258/2 "2007-03-19T03:04:43Z")

</div>

Keynan P. wrote:

> end  
> else  
> It appears as though I don’t have access to any changes to the session
> 
> Does any one know how to make the magic happen?

You haven’t told us which assert you think is supposed to be failing and  
why.

If you want to track the changes to the session object, you can just  
print out its contents in your code and see if things are getting set as  
they should be.

–  
Michael W.

---

<div class="post-metadata">

**Author:** ![keynan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/8dc957/32.png) [@keynan](https://www.ruby-forum.com/u/keynan)\
**Post date:** [March 19, 2007, 4:46am UTC](https://www.ruby-forum.com/t/issues-with-tests/89258/3 "2007-03-19T04:46:51Z")

</div>

Keynan P. wrote:

> the purpose of the first assert is to print the session in the fail  
> message
> 
> all the assertions fail.
> 
> the assigns hash seems to be working but information from session and  
> flash does not change with the request

In Ruby false != 0

–  
Michael W.

---

<div class="post-metadata">

**Author:** ![keynan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/8dc957/32.png) [@keynan](https://www.ruby-forum.com/u/keynan)\
**Post date:** [March 19, 2007, 4:09am UTC](https://www.ruby-forum.com/t/issues-with-tests/89258/4 "2007-03-19T04:09:20Z")

</div>

the purpose of the first assert is to print the session in the fail  
message

all the assertions fail.

the assigns hash seems to be working but information from session and  
flash does not change with the request

---

<div class="post-metadata">

**Author:** ![keynan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/8dc957/32.png) [@keynan](https://www.ruby-forum.com/u/keynan)\
**Post date:** [March 19, 2007, 5:07am UTC](https://www.ruby-forum.com/t/issues-with-tests/89258/5 "2007-03-19T05:07:09Z")

</div>

actually the problem was a security filter was interupting.

p.s. in rails checkboxes 0 is submited and false is stored in the model  
attribute
