Sha256: ee53f5e7832a20dd58bbeeb1b586e49192a05bb1136a76dc8090306f1941ff22

Contents?: true

Size: 1.55 KB

Versions: 15

Compression:

Stored size: 1.55 KB

Contents

require 'test_helper'

module Kaui
  class RegistrationsControllerTest < Kaui::FunctionalTestHelper

    test 'should get new' do
      logout

      get :new
      assert_response :success
      assert has_input_field('user_kb_username'), 'Expected input with id user_kb_username not found'
      assert has_input_field('user_password'), 'Expected input with id user_password not found'
    end

    test 'should get create' do
      logout

      # enable the option of registration
      Kaui.disable_sign_up_link = false

      parameters = {
        :user => {
          :kb_username => 'Voltron',
          :password => 'Voltron'
        }
      }
      post :create, parameters
      assert_equal "User #{parameters[:user][:kb_username]} successfully created, please login", flash[:notice]
      assert_response :redirect
      # validate redirect path
      assert response_path.include?('/users/sign_in'), "#{response_path} is expected to contain /users/sign_in"

      # should return an error that the user already exists
      post :create, parameters
      assert_equal "User with name #{parameters[:user][:kb_username]} already exists!", flash[:error]
      assert_response :success

      # disable the option of registration
      Kaui.disable_sign_up_link = true

      post :create, parameters
      assert_equal 'You need to sign in before adding a user!', flash[:error]
      assert_response :redirect
      # validate redirect path
      assert response_path.include?('/users/sign_in'), "#{response_path} is expected to contain /users/sign_in"
    end

  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
kaui-2.1.0 test/functional/kaui/registrations_controller_test.rb
kaui-2.0.4 test/functional/kaui/registrations_controller_test.rb
kaui-2.0.3 test/functional/kaui/registrations_controller_test.rb
kaui-2.0.2 test/functional/kaui/registrations_controller_test.rb
kaui-2.0.1 test/functional/kaui/registrations_controller_test.rb
kaui-2.0.0 test/functional/kaui/registrations_controller_test.rb
kaui-1.4.1 test/functional/kaui/registrations_controller_test.rb
kaui-1.4.0 test/functional/kaui/registrations_controller_test.rb
kaui-1.3.0 test/functional/kaui/registrations_controller_test.rb
kaui-1.2.0 test/functional/kaui/registrations_controller_test.rb
kaui-1.1.0 test/functional/kaui/registrations_controller_test.rb
kaui-1.0.0 test/functional/kaui/registrations_controller_test.rb
kaui-0.16.2 test/functional/kaui/registrations_controller_test.rb
kaui-0.16.1 test/functional/kaui/registrations_controller_test.rb
kaui-0.16.0 test/functional/kaui/registrations_controller_test.rb