Sha256: e967497c991e547ad64d92770761f53c8df6ce09becec6920a3aff62fa733c33

Contents?: true

Size: 1.08 KB

Versions: 33

Compression:

Stored size: 1.08 KB

Contents

require 'test_helper'

module Adminpanel
  class UserTest < ActiveSupport::TestCase
    setup :assign_user

    def test_is_valid_user
      assert @test_user.save
    end

    def test_name_validation
      @test_user.name = ""
      assert_not @test_user.valid?
    end

    def test_email_validation
      @test_user.email = "foo@"
      assert_not @test_user.valid?

      @test_user.email = "foo@bar"
      assert_not @test_user.valid?

      @test_user.email = "@bar.baz"
      assert_not @test_user.valid?

      @test_user.email = "foo.baz"
      assert_not @test_user.valid?
    end

    def test_password_validation
      @test_user.password_confirmation = "foobaz"
      assert_not @test_user.valid?

      @test_user.password_confirmation = "foo"
      @test_user.password = "foo"
      assert_not @test_user.valid?
    end

  protected
    def assign_user
      @test_user = Adminpanel::User.new(
        name: "Example User",
        email: "foo@bar.com",
        password: "foobar",
        password_confirmation: "foobar",
        role_id: adminpanel_roles(:Admin).id
      )
    end

  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
adminpanel-3.6.1 test/models/adminpanel/user_test.rb
adminpanel-3.6.0 test/models/adminpanel/user_test.rb
adminpanel-3.5.1 test/models/adminpanel/user_test.rb
adminpanel-3.5.0 test/models/adminpanel/user_test.rb
adminpanel-3.4.7 test/models/adminpanel/user_test.rb
adminpanel-3.4.6 test/models/adminpanel/user_test.rb
adminpanel-3.4.5 test/models/adminpanel/user_test.rb
adminpanel-3.4.4 test/models/adminpanel/user_test.rb
adminpanel-3.4.3 test/models/adminpanel/user_test.rb
adminpanel-3.4.2 test/models/adminpanel/user_test.rb
adminpanel-3.4.1 test/models/adminpanel/user_test.rb
adminpanel-3.4.0 test/models/adminpanel/user_test.rb
adminpanel-3.3.4 test/models/adminpanel/user_test.rb
adminpanel-3.3.3 test/models/adminpanel/user_test.rb
adminpanel-3.3.0 test/models/adminpanel/user_test.rb
adminpanel-3.2.1 test/models/adminpanel/user_test.rb
adminpanel-3.2.0 test/models/adminpanel/user_test.rb
adminpanel-3.1.0 test/models/adminpanel/user_test.rb
adminpanel-3.0.0 test/models/adminpanel/user_test.rb
adminpanel-2.6.1 test/models/adminpanel/user_test.rb