diff --git a/app/models/micropost.rb b/app/models/micropost.rb new file mode 100644 index 0000000..788f81d --- /dev/null +++ b/app/models/micropost.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class Micropost < ApplicationRecord + belongs_to :user + has_rich_text :content + + validates :user, presence: true + validates :content, presence: true +end diff --git a/db/migrate/20230917114037_create_microposts.rb b/db/migrate/20230917114037_create_microposts.rb new file mode 100644 index 0000000..e43f36b --- /dev/null +++ b/db/migrate/20230917114037_create_microposts.rb @@ -0,0 +1,9 @@ +class CreateMicroposts < ActiveRecord::Migration[7.0] + def change + create_table :microposts do |t| + t.references :user, null: false, foreign_key: true + + t.timestamps + end + end +end diff --git a/test/fixtures/action_text/rich_texts.yml b/test/fixtures/action_text/rich_texts.yml index 8b371ea..a751005 100644 --- a/test/fixtures/action_text/rich_texts.yml +++ b/test/fixtures/action_text/rich_texts.yml @@ -1,4 +1,4 @@ -# one: -# record: name_of_fixture (ClassOfFixture) -# name: content -# body:

In a million stars!

+one: + record: some_text (Micropost) + name: content + body:

Just some text

diff --git a/test/fixtures/microposts.yml b/test/fixtures/microposts.yml new file mode 100644 index 0000000..26c2649 --- /dev/null +++ b/test/fixtures/microposts.yml @@ -0,0 +1,2 @@ +some_text: + user: gimli diff --git a/test/models/micropost_test.rb b/test/models/micropost_test.rb new file mode 100644 index 0000000..9a20fe6 --- /dev/null +++ b/test/models/micropost_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class MicropostTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end