summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Gay <david@davidgay.org>2021-04-06 20:01:27 -0400
committerDavid Gay <david@davidgay.org>2021-04-06 20:01:27 -0400
commitbf4912554058164fabd410b3082b6aa53e7ed026 (patch)
tree24548647d3b6de7b7287dbe90958ee3eda9c665d
parent1d3c909a2fe818935afc7b4b60ea31c2cf3852fd (diff)
PTU frequencies
-rw-r--r--app/models/ptu_frequency.rb3
-rw-r--r--db/migrate/20210406235514_create_ptu_frequencies.rb9
-rw-r--r--db/schema.rb8
-rw-r--r--db/seeds.rb4
-rw-r--r--test/fixtures/ptu_frequencies.yml7
-rw-r--r--test/models/ptu_frequency_test.rb9
-rw-r--r--test/models/ptu_type_test.rb2
7 files changed, 40 insertions, 2 deletions
diff --git a/app/models/ptu_frequency.rb b/app/models/ptu_frequency.rb
new file mode 100644
index 0000000..f7f9f53
--- /dev/null
+++ b/app/models/ptu_frequency.rb
@@ -0,0 +1,3 @@
+class PtuFrequency < ApplicationRecord
+ validates :name, presence: true
+end
diff --git a/db/migrate/20210406235514_create_ptu_frequencies.rb b/db/migrate/20210406235514_create_ptu_frequencies.rb
new file mode 100644
index 0000000..4f89f2c
--- /dev/null
+++ b/db/migrate/20210406235514_create_ptu_frequencies.rb
@@ -0,0 +1,9 @@
+class CreatePtuFrequencies < ActiveRecord::Migration[6.1]
+ def change
+ create_table :ptu_frequencies do |t|
+ t.string :name
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 3e9fd9d..af23532 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,11 +10,17 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 2021_04_06_234544) do
+ActiveRecord::Schema.define(version: 2021_04_06_235514) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
+ create_table "ptu_frequencies", force: :cascade do |t|
+ t.string "name"
+ t.datetime "created_at", precision: 6, null: false
+ t.datetime "updated_at", precision: 6, null: false
+ end
+
create_table "ptu_types", force: :cascade do |t|
t.string "name"
t.datetime "created_at", precision: 6, null: false
diff --git a/db/seeds.rb b/db/seeds.rb
index 929b525..efd1ce7 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -8,3 +8,7 @@
%w[Normal Fire Water Grass Electric Ice Fighting Poison Ground Flying Psychic
Bug Rock Ghost Dark Dragon Steel Fairy].each { |name| PtuType.find_or_create_by(name: name) }
+
+["Static", "At-Will", "EOT", "Scene", "Scene x2", "Scene x3", "Daily"].each do |name|
+ PtuFrequency.find_or_create_by(name: name)
+end
diff --git a/test/fixtures/ptu_frequencies.yml b/test/fixtures/ptu_frequencies.yml
new file mode 100644
index 0000000..771941d
--- /dev/null
+++ b/test/fixtures/ptu_frequencies.yml
@@ -0,0 +1,7 @@
+# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+one:
+ name: At-Will
+
+two:
+ name: Scene
diff --git a/test/models/ptu_frequency_test.rb b/test/models/ptu_frequency_test.rb
new file mode 100644
index 0000000..5ebc48c
--- /dev/null
+++ b/test/models/ptu_frequency_test.rb
@@ -0,0 +1,9 @@
+require "test_helper"
+
+class PtuFrequencyTest < ActiveSupport::TestCase
+ test "can create" do
+ assert_difference("PtuFrequency.count", 1) do
+ PtuFrequency.create(name: "Whenever")
+ end
+ end
+end
diff --git a/test/models/ptu_type_test.rb b/test/models/ptu_type_test.rb
index f7666df..39bfcfc 100644
--- a/test/models/ptu_type_test.rb
+++ b/test/models/ptu_type_test.rb
@@ -1,7 +1,7 @@
require "test_helper"
class PtuTypeTest < ActiveSupport::TestCase
- test "can create type" do
+ test "can create" do
assert_difference("PtuType.count", 1) do
PtuType.create(name: "TestType")
end