# Ruby Calculator - Interactive calculator built with Ruby on Rails
# Author: RSK World (Molla Samser, Founder | Rima Khatun, Designer & Tester)
# Contact: help@rskworld.in | +91 93305 39277
# Website: https://rskworld.in
# Year: 2026
# Description: Build a fully functional calculator using Ruby on Rails with modern UI

require "test_helper"

class CalculatorControllerTest < ActionDispatch::IntegrationTest
  test "should get index" do
    get calculator_index_url
    assert_response :success
  end

  test "should perform addition" do
    post calculator_calculate_url, params: { 
      operation: 'add', 
      first_number: 5, 
      second_number: 3 
    }
    assert_response :success
  end

  test "should perform subtraction" do
    post calculator_calculate_url, params: { 
      operation: 'subtract', 
      first_number: 10, 
      second_number: 4 
    }
    assert_response :success
  end

  test "should perform multiplication" do
    post calculator_calculate_url, params: { 
      operation: 'multiply', 
      first_number: 6, 
      second_number: 7 
    }
    assert_response :success
  end

  test "should perform division" do
    post calculator_calculate_url, params: { 
      operation: 'divide', 
      first_number: 20, 
      second_number: 4 
    }
    assert_response :success
  end

  test "should handle division by zero" do
    post calculator_calculate_url, params: { 
      operation: 'divide', 
      first_number: 10, 
      second_number: 0 
    }
    assert_response :success
  end

  test "should perform square root" do
    post calculator_calculate_url, params: { 
      operation: 'sqrt', 
      first_number: 16, 
      second_number: 0 
    }
    assert_response :success
  end

  test "should perform power operation" do
    post calculator_calculate_url, params: { 
      operation: 'power', 
      first_number: 2, 
      second_number: 3 
    }
    assert_response :success
  end

  test "should handle memory operations" do
    post calculator_memory_url, params: { 
      memory_action: 'add', 
      value: 10 
    }
    assert_response :success
  end

  test "should get history" do
    get calculator_history_url
    assert_response :success
  end
end
