diff --git a/.gitignore b/.gitignore index e16dc71..ff8c9d7 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,9 @@ # or operating system, you probably want to add a global ignore instead: # git config --global core.excludesfile '~/.gitignore_global' +**/.keep +**/.core + # Ignore bundler config. /.bundle diff --git a/app/models/virtual.rb b/app/models/virtual.rb index 5759752..bdd9882 100644 --- a/app/models/virtual.rb +++ b/app/models/virtual.rb @@ -1,2 +1,4 @@ class Virtual < ApplicationRecord + validates :email, presence: true + validates :destination, presence: true end diff --git a/db/schema.rb b/db/schema.rb index 0bea432..92a327b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,14 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_05_10_141218) do +ActiveRecord::Schema[7.0].define(version: 2023_05_10_184959) do + create_table "credentials", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t| + t.string "email" + t.string "password" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "domains", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t| t.string "domain" t.datetime "created_at", null: false diff --git a/test/fixtures/.credentials.yml.kate-swp b/test/fixtures/.credentials.yml.kate-swp new file mode 100644 index 0000000..d7ae1f5 Binary files /dev/null and b/test/fixtures/.credentials.yml.kate-swp differ diff --git a/test/models/.virtual_test.rb.kate-swp b/test/models/.virtual_test.rb.kate-swp deleted file mode 100644 index f2a3218..0000000 Binary files a/test/models/.virtual_test.rb.kate-swp and /dev/null differ diff --git a/test/models/virtual_test.rb b/test/models/virtual_test.rb index affa4d1..e91bf79 100644 --- a/test/models/virtual_test.rb +++ b/test/models/virtual_test.rb @@ -1,7 +1,34 @@ require "test_helper" class VirtualTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end + test "the email cant be blank" do + @v = Virtual.new + @v.destination = "davesmith@example.com" + assert !@v.save + end + + test "the destination email cant be blank" do + @v = Virtual.new + @v.email = "davesmith@example.com" + assert !@v.save + end + + test "the domain name of the email must be on this server" do + @v = Virtual.new + @v.email = "davesmith@notonthisserver.com" + @v.destination = "bob@example.net" + assert !@v.save + end + + test "the email must be a valid email" do + # flunk() + end + + test "the destination must be a valid email" do + # flunk() + end + + test "the email plus destination must be unique" do + # flunk() + end end