From 2488d3073aa911ec52da97aea13807772aef0ea4 Mon Sep 17 00:00:00 2001 From: Simon Quigley Date: Mon, 25 Sep 2023 13:24:55 -0500 Subject: [PATCH] Complete exercise 4 --- app/models/movie.rb | 2 ++ db/migrate/20230925181424_create_movies.rb | 11 +++++++++++ db/schema.rb | 22 ++++++++++++++++++++++ test/fixtures/movies.yml | 11 +++++++++++ test/models/movie_test.rb | 7 +++++++ 5 files changed, 53 insertions(+) create mode 100644 app/models/movie.rb create mode 100644 db/migrate/20230925181424_create_movies.rb create mode 100644 db/schema.rb create mode 100644 test/fixtures/movies.yml create mode 100644 test/models/movie_test.rb diff --git a/app/models/movie.rb b/app/models/movie.rb new file mode 100644 index 0000000..dc614df --- /dev/null +++ b/app/models/movie.rb @@ -0,0 +1,2 @@ +class Movie < ApplicationRecord +end diff --git a/db/migrate/20230925181424_create_movies.rb b/db/migrate/20230925181424_create_movies.rb new file mode 100644 index 0000000..0454ed7 --- /dev/null +++ b/db/migrate/20230925181424_create_movies.rb @@ -0,0 +1,11 @@ +class CreateMovies < ActiveRecord::Migration[7.0] + def change + create_table :movies do |t| + t.string :title + t.string :rating + t.decimal :total_gross + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 0000000..d55f641 --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,22 @@ +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# This file is the source Rails uses to define your schema when running `bin/rails +# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to +# be faster and is potentially less error prone than running all of your +# migrations from scratch. Old migrations may fail to apply correctly if those +# migrations use external dependencies or application code. +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema[7.0].define(version: 2023_09_25_181424) do + create_table "movies", force: :cascade do |t| + t.string "title" + t.string "rating" + t.decimal "total_gross" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + +end diff --git a/test/fixtures/movies.yml b/test/fixtures/movies.yml new file mode 100644 index 0000000..325b67a --- /dev/null +++ b/test/fixtures/movies.yml @@ -0,0 +1,11 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + title: MyString + rating: MyString + total_gross: 9.99 + +two: + title: MyString + rating: MyString + total_gross: 9.99 diff --git a/test/models/movie_test.rb b/test/models/movie_test.rb new file mode 100644 index 0000000..c81cd39 --- /dev/null +++ b/test/models/movie_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class MovieTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end