Sha256: 44dce1282f9346362860782822d661bf8effe3fb408303c2c333fa3666bd86ba

Contents?: true

Size: 1.01 KB

Versions: 10

Compression:

Stored size: 1.01 KB

Contents

require 'test_controller'
require 'editor/test_helper'

class SessionsControllerTest < TestController
  test 'should be able to log in' do
    post :create, session: {email: "pothibo@gmail.com", password: "123456789"}
    assert !proxy.user.nil?, "#{users(:pothibo).email} should be logged in"
    assert_redirected_to '/'
  end


  # From what I could read, functional tests do not play nice with middlewares.
  # So, because I can't rely on Warden::Manager to catch the thrown error here, I 
  # have 2 options: Move to integration testing or work around the issue. 
  # I chose the later for now but I believe that it might be a good idea to move controller
  # testing to actual integration tests. Most of the work is done on the UI anyway so it would
  # cover every cases. 
  test 'show and error if your credentials do not satisfy' do
    catch :warden do
      post :create, session: {email: "pothibo@gmail.com", password: "ksjaslk"}
    end
    assert proxy.user.nil?, "#{users(:pothibo).email} should NOT be logged in"
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ecrire-0.27.0 test/editor/controllers/sessions_controller_test.rb
ecrire-0.26.3 test/editor/controllers/sessions_controller_test.rb
ecrire-0.26.2 test/editor/controllers/sessions_controller_test.rb
ecrire-0.26.1 test/editor/controllers/sessions_controller_test.rb
ecrire-0.26.0 test/editor/controllers/sessions_controller_test.rb
ecrire-0.25.2 test/editor/controllers/sessions_controller_test.rb
ecrire-0.25.1 test/editor/controllers/sessions_controller_test.rb
ecrire-0.25.0 test/editor/controllers/sessions_controller_test.rb
ecrire-0.24.1 test/editor/controllers/sessions_controller_test.rb
ecrire-0.24.0 test/editor/controllers/sessions_controller_test.rb