help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
ruby-todo-list
/
test
/
models
RSK World
ruby-todo-list
Ruby Todo List - Task Management with User Authentication + Categories + Search + File Attachments + Email Notifications + Rails MVC + Modern Web Interface + API Integration + Educational Design
models
  • category_test.rb1.4 KB
  • task_test.rb2.2 KB
category_test.rb
test/models/category_test.rb
Raw Download
Find: Go to:
# Ruby To-Do List Application - Category Model Test
# Created by: Molla Samser (help@rskworld.in, +91 93305 39277)
# Address: Nutanhat, Mongolkote, Purba Burdwan, West Bengal, India, 713147
# Year: 2026

require "test_helper"

class CategoryTest < ActiveSupport::TestCase
  setup do
    @user = users(:one)
    @category = @user.categories.build(name: "Test Category", color: "#ff0000")
  end

  test "should be valid" do
    assert @category.valid?
  end

  test "name should be present" do
    @category.name = ""
    assert_not @category.valid?
  end

  test "name should be unique per user" do
    @category.save
    duplicate_category = @user.categories.build(name: "Test Category", color: "#00ff00")
    assert_not duplicate_category.valid?
  end

  test "color should be valid hex format" do
    @category.color = "invalid"
    assert_not @category.valid?

    @category.color = "#ff0000"
    assert @category.valid?
  end

  test "should belong to user" do
    assert_respond_to @category, :user
  end

  test "should have many tasks" do
    assert_respond_to @category, :tasks
  end

  test "should create default categories for new user" do
    user = User.create(email: "test@example.com", password: "password123")
    assert_equal 5, user.categories.count
    assert user.categories.pluck(:name).include?("Work")
    assert user.categories.pluck(:name).include?("Personal")
  end
end
51 lines•1.4 KB
ruby

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer