ruby on rails 3 - Why is capybara/rspec losing the current_user? -


The following device is failing and failing again. I have tried everything, but I can not get it to work if I test it manually so it looks okay: (some help / tips will really look good!)

Connect The action must be added to a guild / group logged-in user, if it is the correct token URL). If the user is not logged in, then the action redirects to the login page and redirects tokens and IDs to cookies. After login, the user is redirected to the join page if cookies are set.

I have found that the current_com is finished during the trial. Session variable still exists. I have a standard Authlogic setup and all other tests are passing, so I really do not know what's wrong. 'New to RSPC / Capibara, but the Cucumber / Capibara Test (from which I am migrating) has also been unsuccessful, so I think that this is a symptom of the symbiosis.

  Description Guilds Controller do fixture: Roles Def login @ user = factory (: user) Login 'to log in' login, fill with = & Gt; @ User.login fill_in 'password', with: = with & gt; Click 'Password' on the 'Login' page. Shaw Ld has_css ("Information") end def assing_user_to_guild_as (role) role_id = Role.where (: name = & gt; role). First.id@gild.assignments & lt; & Lt; Assignment.new (: role_id = & gt; role_id ,: user_id = & gt; @ user.id ,: guild_id = & gt; @ guild.id) before (: each) do @guild = guild.fest || Factory (: Guild). Build visit Root_Path and Practical "Before a User" (Login: Each) Login, it should be able to "Join a Guild with a valid token" "Go to Guilds / # {@ guild.id}" / join /#{@guild.token} "@ guild.members.include? (@ User.login) .should be_true page.should be css (" notice ") it should not be able to join a Guild with" End " An illegal token "travel" guilds / # {@ guild.id} / join / # {@ guild.token + "invalid"} "@ guild.members.include?" (@ User.login). Be_false page.should if_css (".error") end-end  

Controller action:

  join join DR @ guild = guild.fund (param [: Id]) Answer | Format | If current_user.nil? Flash [: Error] = T ("has_to_be_logged_in") until the consultation [: token]. Cookies [: rguilds_jg_token] = params [: tokens] cookies [: rguilds_jg_gid] = params [: id] end format.html {redirect_to (login_path)} and cookies until [: rguilds_jg_token] .nil? & Amp; & Amp; Cookies [: rguilds_jg_gid] .nil? Cookies.delete (: rguilds_jg_token) cookies.delete (: rguilds_jg_gid) if end @ guild.verified? If the consultation [: token] is not up to date = guild.token @guild.users.include? (Current_USUG) @ federal contract & Lt; & Lt; Assignment.create (: user_id = & gt; current_user.id ,: role_id => Role.find_by_name ("member"). Id) Flash [: notice] = t ('guilds.joined') format.html {redirect_to ([Guild]} and flash [: error] = t ('guilds.already_joined') format.html {redirect_to (@guild)} and flash [: error] = t ('guilds.invalid_token') format.html { Redirect_to (@gold)} end and flash [: error] = t ('guilds.not_verified') format.html {redirect_to (@guild)} and end and end  

"rack Space "Result:

...................ff ................ ... ............................................... ... Failures: 1) Guild Controller A user must have a proper tow Not be able to join in a consortium with the failure / error: @ guild.members.include? (@ User.login). Be_true Required To Be Wrong In Wrong ## / spec / Integration / Guilds_spec.rb: 72: In `` Block (Level 3) & lt; Top (required) & gt; 2) Guild Controller A user should not be able to join a Guild with an invalid token failure / error: Page. True, the # to get the css ("error.") #has_css? ("Error") is expected. /spec/integration/guilds_spec.rb:79:in `Block (level 3) & lt; Top (required) & gt; '90 examples ending in 7.87 seconds, 2 failure

Gem:

  Mani' rail ',' 3.0.0.rc 'gem "Mocha" mani "Rspec-rails", "& gt; = 2.0.0.beta.19" Mani "Factory _Gael_Rales" Mani 'Capibara' Mani "Oothlogic",: git = & gt; "Http://github.com/odorcicd/authlogic.git",: Branch => "Train 3"  

  # your test_helper.rb / spec_helper.rb class ActiveRecord :: Base Matrix_asserus: shared_connection @@ shared_connection = nil def self.connection @@ shared_connection || Recovery_connection end time # forces all threads to share the same connection. It works on #capabara because it starts the Web server in a thread ActiveRecord :: Base.shared_connection = ActiveRecord :: base.canation  

this


Comments