From 63d4c442cc0e96df8758e7dca6793adb30074bb2 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 12 Jul 2017 20:03:38 +0100 Subject: [PATCH] Add content changelogs #migration --- app/assets/stylesheets/content.css.scss | 9 + app/models/concerns/has_changelog.rb | 41 +++ app/models/content_change_event.rb | 5 + app/models/content_types/character.rb | 1 + app/models/content_types/creature.rb | 2 + app/models/content_types/group.rb | 2 + app/models/content_types/item.rb | 2 + app/models/content_types/language.rb | 2 + app/models/content_types/location.rb | 2 + app/models/content_types/magic.rb | 2 + app/models/content_types/race.rb | 2 + app/models/content_types/religion.rb | 2 + app/models/content_types/scene.rb | 2 + app/models/content_types/universe.rb | 2 + app/models/user.rb | 2 + app/views/content/display/_changelog.html.erb | 49 ++++ app/views/content/display/_sidelinks.html.erb | 6 + app/views/content/show.html.erb | 5 + config/attributes/character.yml | 3 + config/attributes/creature.yml | 3 + config/attributes/group.yml | 3 + config/attributes/item.yml | 3 + config/attributes/language.yml | 3 + config/attributes/location.yml | 3 + config/attributes/magic.yml | 3 + config/attributes/race.yml | 3 + config/attributes/religion.yml | 3 + config/attributes/scene.yml | 3 + config/attributes/universe.yml | 3 + ...0712190101_create_content_change_events.rb | 13 + db/schema.rb | 266 +++++++++++++++++- test/fixtures/content_change_events.yml | 15 + test/models/content_change_event_test.rb | 7 + 33 files changed, 471 insertions(+), 1 deletion(-) create mode 100644 app/models/concerns/has_changelog.rb create mode 100644 app/models/content_change_event.rb create mode 100644 app/views/content/display/_changelog.html.erb create mode 100644 db/migrate/20170712190101_create_content_change_events.rb create mode 100644 test/fixtures/content_change_events.yml create mode 100644 test/models/content_change_event_test.rb diff --git a/app/assets/stylesheets/content.css.scss b/app/assets/stylesheets/content.css.scss index 5bfe3150..7c03e50a 100644 --- a/app/assets/stylesheets/content.css.scss +++ b/app/assets/stylesheets/content.css.scss @@ -85,4 +85,13 @@ p.long-form { p { margin-bottom: 18px !important; } +} + +.changelog { + td { + padding-top: 10px; + padding-bottom: 10px; + } + + margin-bottom: 30px; } \ No newline at end of file diff --git a/app/models/concerns/has_changelog.rb b/app/models/concerns/has_changelog.rb new file mode 100644 index 00000000..684918d8 --- /dev/null +++ b/app/models/concerns/has_changelog.rb @@ -0,0 +1,41 @@ +require 'active_support/concern' + +module HasChangelog + extend ActiveSupport::Concern + + included do + def change_events + ContentChangeEvent.where(content_id: id, content_type: self.class.name).order(:id) + end + + after_create do + ContentChangeEvent.create( + user: user, + changed_fields: changes, + content_id: id, + content_type: self.class.name, + action: :created + ) + end + + after_update do + ContentChangeEvent.create( + user: user, + changed_fields: changes, + content_id: id, + content_type: self.class.name, + action: :updated + ) if changes.any? + end + + before_destroy do + ContentChangeEvent.create( + user: user, + changed_fields: changes, + content_id: id, + content_type: self.class.name, + action: :deleted + ) + end + end +end diff --git a/app/models/content_change_event.rb b/app/models/content_change_event.rb new file mode 100644 index 00000000..e98388ab --- /dev/null +++ b/app/models/content_change_event.rb @@ -0,0 +1,5 @@ +class ContentChangeEvent < ActiveRecord::Base + belongs_to :user + + serialize :changed_fields, Hash +end diff --git a/app/models/content_types/character.rb b/app/models/content_types/character.rb index 29518e9f..db5e1739 100644 --- a/app/models/content_types/character.rb +++ b/app/models/content_types/character.rb @@ -18,6 +18,7 @@ class Character < ActiveRecord::Base include HasPrivacy include HasContentGroupers include HasImageUploads + include HasChangelog include Serendipitous::Concern diff --git a/app/models/content_types/creature.rb b/app/models/content_types/creature.rb index bf79df57..3be257d2 100644 --- a/app/models/content_types/creature.rb +++ b/app/models/content_types/creature.rb @@ -18,6 +18,8 @@ class Creature < ActiveRecord::Base include HasPrivacy include HasContentGroupers include HasImageUploads + include HasChangelog + include Serendipitous::Concern include Authority::Abilities diff --git a/app/models/content_types/group.rb b/app/models/content_types/group.rb index b10c038d..ffe35739 100644 --- a/app/models/content_types/group.rb +++ b/app/models/content_types/group.rb @@ -10,6 +10,8 @@ class Group < ActiveRecord::Base include HasPrivacy include HasContentGroupers include HasImageUploads + include HasChangelog + include Serendipitous::Concern include Authority::Abilities diff --git a/app/models/content_types/item.rb b/app/models/content_types/item.rb index d8551a70..b2103eff 100644 --- a/app/models/content_types/item.rb +++ b/app/models/content_types/item.rb @@ -16,6 +16,8 @@ class Item < ActiveRecord::Base include HasPrivacy include HasContentGroupers include HasImageUploads + include HasChangelog + include Serendipitous::Concern include Authority::Abilities diff --git a/app/models/content_types/language.rb b/app/models/content_types/language.rb index 48d28c13..317f0e70 100644 --- a/app/models/content_types/language.rb +++ b/app/models/content_types/language.rb @@ -10,6 +10,8 @@ class Language < ActiveRecord::Base include HasPrivacy include HasContentGroupers include HasImageUploads + include HasChangelog + include Serendipitous::Concern include Authority::Abilities diff --git a/app/models/content_types/location.rb b/app/models/content_types/location.rb index fb565239..780061d0 100644 --- a/app/models/content_types/location.rb +++ b/app/models/content_types/location.rb @@ -19,6 +19,8 @@ class Location < ActiveRecord::Base include HasPrivacy include HasContentGroupers include HasImageUploads + include HasChangelog + include Serendipitous::Concern include Authority::Abilities diff --git a/app/models/content_types/magic.rb b/app/models/content_types/magic.rb index b8acc3f3..dea45cb7 100644 --- a/app/models/content_types/magic.rb +++ b/app/models/content_types/magic.rb @@ -10,6 +10,8 @@ class Magic < ActiveRecord::Base include HasPrivacy include HasContentGroupers include HasImageUploads + include HasChangelog + include Serendipitous::Concern include Authority::Abilities diff --git a/app/models/content_types/race.rb b/app/models/content_types/race.rb index adfe7125..8ec8bd6e 100644 --- a/app/models/content_types/race.rb +++ b/app/models/content_types/race.rb @@ -16,6 +16,8 @@ class Race < ActiveRecord::Base include HasPrivacy include HasContentGroupers include HasImageUploads + include HasChangelog + include Serendipitous::Concern include Authority::Abilities diff --git a/app/models/content_types/religion.rb b/app/models/content_types/religion.rb index 5e6cc4bd..879daaf9 100644 --- a/app/models/content_types/religion.rb +++ b/app/models/content_types/religion.rb @@ -10,6 +10,8 @@ class Religion < ActiveRecord::Base include HasPrivacy include HasContentGroupers include HasImageUploads + include HasChangelog + include Serendipitous::Concern include Authority::Abilities diff --git a/app/models/content_types/scene.rb b/app/models/content_types/scene.rb index 5d4b3e71..35300ec9 100644 --- a/app/models/content_types/scene.rb +++ b/app/models/content_types/scene.rb @@ -10,6 +10,8 @@ class Scene < ActiveRecord::Base include HasPrivacy include HasContentGroupers include HasImageUploads + include HasChangelog + include Serendipitous::Concern include Authority::Abilities diff --git a/app/models/content_types/universe.rb b/app/models/content_types/universe.rb index f5a7d2c5..6e22fdfc 100644 --- a/app/models/content_types/universe.rb +++ b/app/models/content_types/universe.rb @@ -10,6 +10,8 @@ class Universe < ActiveRecord::Base include HasAttributes include HasPrivacy include HasImageUploads + include HasChangelog + include Serendipitous::Concern include Authority::Abilities diff --git a/app/models/user.rb b/app/models/user.rb index bd6a9420..19c217b2 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -28,6 +28,8 @@ class User < ActiveRecord::Base has_many :votes has_many :raffle_entries + has_many :content_change_events + # TODO: Swap this out with a has_many when we transition from a scratchpad to users having multiple documents has_one :document diff --git a/app/views/content/display/_changelog.html.erb b/app/views/content/display/_changelog.html.erb new file mode 100644 index 00000000..75e0d92f --- /dev/null +++ b/app/views/content/display/_changelog.html.erb @@ -0,0 +1,49 @@ +
Changelog for <%= content.name %>
+ + \ No newline at end of file diff --git a/app/views/content/display/_sidelinks.html.erb b/app/views/content/display/_sidelinks.html.erb index 04f63b21..9af6945b 100644 --- a/app/views/content/display/_sidelinks.html.erb +++ b/app/views/content/display/_sidelinks.html.erb @@ -19,8 +19,14 @@ <% @content.class.attribute_categories(current_user).each do |category| %> <% fields = category.attribute_fields %> <% + #TODO: refactor ALL OF THIS + # Don't show changelog tab on create/edit form + next if (creating || editing) && category.name == 'changelog' + if creating || editing # Show everything on create/edit forms + elsif category.name == 'changelog' + # Show changelog on show page elsif category.name == 'gallery' # Only show gallery tab if the content has any images next if @content.image_uploads.empty? diff --git a/app/views/content/show.html.erb b/app/views/content/show.html.erb index d32e4269..acb35781 100644 --- a/app/views/content/show.html.erb +++ b/app/views/content/show.html.erb @@ -28,6 +28,11 @@ <%= render partial: 'content/form/images/gallery', locals: { content: content } %> <% end %> + <% if category.name == 'changelog' %> +
+ <%= render partial: 'content/display/changelog', locals: { content: content } %> +
+ <% end %> <% category.attribute_fields.each do |attribute| %> <% next if attribute.name.start_with?("private") && (current_user.nil? || @content.user != current_user) %> diff --git a/config/attributes/character.yml b/config/attributes/character.yml index 938f42e8..137cdbc8 100644 --- a/config/attributes/character.yml +++ b/config/attributes/character.yml @@ -113,6 +113,9 @@ :gallery: :label: Gallery :icon: photo_library +:changelog: + :label: Changelog + :icon: history :notes: :label: Notes :icon: edit diff --git a/config/attributes/creature.yml b/config/attributes/creature.yml index 40d101bc..9a4cdf52 100644 --- a/config/attributes/creature.yml +++ b/config/attributes/creature.yml @@ -73,6 +73,9 @@ :gallery: :label: Gallery :icon: photo_library +:changelog: + :label: Changelog + :icon: history :notes: :label: Notes :icon: edit diff --git a/config/attributes/group.yml b/config/attributes/group.yml index 48e3c5bb..4603156b 100644 --- a/config/attributes/group.yml +++ b/config/attributes/group.yml @@ -75,6 +75,9 @@ :gallery: :label: Gallery :icon: photo_library +:changelog: + :label: Changelog + :icon: history :notes: :label: Notes :icon: edit diff --git a/config/attributes/item.yml b/config/attributes/item.yml index 21bd4630..1f1dca07 100644 --- a/config/attributes/item.yml +++ b/config/attributes/item.yml @@ -41,6 +41,9 @@ :gallery: :label: Gallery :icon: photo_library +:changelog: + :label: Changelog + :icon: history :notes: :label: Notes :icon: edit diff --git a/config/attributes/language.yml b/config/attributes/language.yml index 8aecca74..6f23152e 100644 --- a/config/attributes/language.yml +++ b/config/attributes/language.yml @@ -43,6 +43,9 @@ :gallery: :label: Gallery :icon: photo_library +:changelog: + :label: Changelog + :icon: history :notes: :label: Notes :icon: edit diff --git a/config/attributes/location.yml b/config/attributes/location.yml index 541d695d..85052a05 100644 --- a/config/attributes/location.yml +++ b/config/attributes/location.yml @@ -65,6 +65,9 @@ :gallery: :label: Gallery :icon: photo_library +:changelog: + :label: Changelog + :icon: history :notes: :label: Notes :icon: edit diff --git a/config/attributes/magic.yml b/config/attributes/magic.yml index a3f769b9..dd5aa0e7 100644 --- a/config/attributes/magic.yml +++ b/config/attributes/magic.yml @@ -51,6 +51,9 @@ :gallery: :label: Gallery :icon: photo_library +:changelog: + :label: Changelog + :icon: history :notes: :label: Notes :icon: edit diff --git a/config/attributes/race.yml b/config/attributes/race.yml index a724c0be..23790708 100644 --- a/config/attributes/race.yml +++ b/config/attributes/race.yml @@ -65,6 +65,9 @@ :gallery: :label: Gallery :icon: photo_library +:changelog: + :label: Changelog + :icon: history :notes: :label: Notes :icon: edit diff --git a/config/attributes/religion.yml b/config/attributes/religion.yml index a2059031..5f144e71 100644 --- a/config/attributes/religion.yml +++ b/config/attributes/religion.yml @@ -59,6 +59,9 @@ :gallery: :label: Gallery :icon: photo_library +:changelog: + :label: Changelog + :icon: history :notes: :label: Notes :icon: edit diff --git a/config/attributes/scene.yml b/config/attributes/scene.yml index 2bd46245..0dbc6f9e 100644 --- a/config/attributes/scene.yml +++ b/config/attributes/scene.yml @@ -31,6 +31,9 @@ :gallery: :label: Gallery :icon: photo_library +:changelog: + :label: Changelog + :icon: history :notes: :label: Notes :icon: edit diff --git a/config/attributes/universe.yml b/config/attributes/universe.yml index 4c8615f3..fd26ab1f 100644 --- a/config/attributes/universe.yml +++ b/config/attributes/universe.yml @@ -35,6 +35,9 @@ :gallery: :label: Gallery :icon: photo_library +:changelog: + :label: Changelog + :icon: history :settings: :label: Settings :icon: build diff --git a/db/migrate/20170712190101_create_content_change_events.rb b/db/migrate/20170712190101_create_content_change_events.rb new file mode 100644 index 00000000..f4729472 --- /dev/null +++ b/db/migrate/20170712190101_create_content_change_events.rb @@ -0,0 +1,13 @@ +class CreateContentChangeEvents < ActiveRecord::Migration + def change + create_table :content_change_events do |t| + t.references :user, index: true, foreign_key: true + t.text :changed_fields + t.integer :content_id + t.string :content_type + t.string :action + + t.timestamps null: false + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 348983c7..db4a09fd 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170517164648) do +ActiveRecord::Schema.define(version: 20170712190101) do create_table "archenemyships", force: :cascade do |t| t.integer "user_id" @@ -157,6 +157,18 @@ ActiveRecord::Schema.define(version: 20170517164648) do t.integer "child_id" end + create_table "content_change_events", force: :cascade do |t| + t.integer "user_id" + t.text "changed_fields" + t.integer "content_id" + t.string "content_type" + t.string "action" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "content_change_events", ["user_id"], name: "index_content_change_events_on_user_id" + create_table "creature_relationships", force: :cascade do |t| t.integer "user_id" t.integer "creature_id" @@ -234,6 +246,19 @@ ActiveRecord::Schema.define(version: 20170517164648) do t.datetime "updated_at", null: false end + create_table "friendly_id_slugs", force: :cascade do |t| + t.string "slug", null: false + t.integer "sluggable_id", null: false + t.string "sluggable_type", limit: 50 + t.string "scope" + t.datetime "created_at" + end + + add_index "friendly_id_slugs", ["slug", "sluggable_type", "scope"], name: "index_friendly_id_slugs_on_slug_and_sluggable_type_and_scope", unique: true + add_index "friendly_id_slugs", ["slug", "sluggable_type"], name: "index_friendly_id_slugs_on_slug_and_sluggable_type" + add_index "friendly_id_slugs", ["sluggable_id"], name: "index_friendly_id_slugs_on_sluggable_id" + add_index "friendly_id_slugs", ["sluggable_type"], name: "index_friendly_id_slugs_on_sluggable_type" + create_table "group_allyships", force: :cascade do |t| t.integer "user_id" t.integer "group_id" @@ -699,6 +724,245 @@ ActiveRecord::Schema.define(version: 20170517164648) do t.integer "supergroup_id" end + create_table "thredded_categories", force: :cascade do |t| + t.integer "messageboard_id", null: false + t.string "name", limit: 191, null: false + t.string "description", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "slug", limit: 191, null: false + end + + add_index "thredded_categories", ["messageboard_id", "slug"], name: "index_thredded_categories_on_messageboard_id_and_slug", unique: true + add_index "thredded_categories", ["messageboard_id"], name: "index_thredded_categories_on_messageboard_id" + add_index "thredded_categories", ["name"], name: "thredded_categories_name_ci" + + create_table "thredded_messageboard_groups", force: :cascade do |t| + t.string "name" + t.integer "position", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "thredded_messageboard_notifications_for_followed_topics", force: :cascade do |t| + t.integer "user_id", null: false + t.integer "messageboard_id", null: false + t.string "notifier_key", limit: 90, null: false + t.boolean "enabled", default: true, null: false + end + + add_index "thredded_messageboard_notifications_for_followed_topics", ["user_id", "messageboard_id", "notifier_key"], name: "thredded_messageboard_notifications_for_followed_topics_unique", unique: true + + create_table "thredded_messageboard_users", force: :cascade do |t| + t.integer "thredded_user_detail_id", null: false + t.integer "thredded_messageboard_id", null: false + t.datetime "last_seen_at", null: false + end + + add_index "thredded_messageboard_users", ["thredded_messageboard_id", "last_seen_at"], name: "index_thredded_messageboard_users_for_recently_active" + add_index "thredded_messageboard_users", ["thredded_messageboard_id", "thredded_user_detail_id"], name: "index_thredded_messageboard_users_primary" + + create_table "thredded_messageboards", force: :cascade do |t| + t.string "name", limit: 191, null: false + t.string "slug", limit: 191 + t.text "description" + t.integer "topics_count", default: 0 + t.integer "posts_count", default: 0 + t.integer "position", null: false + t.integer "last_topic_id" + t.integer "messageboard_group_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "thredded_messageboards", ["messageboard_group_id"], name: "index_thredded_messageboards_on_messageboard_group_id" + add_index "thredded_messageboards", ["slug"], name: "index_thredded_messageboards_on_slug" + + create_table "thredded_notifications_for_followed_topics", force: :cascade do |t| + t.integer "user_id", null: false + t.string "notifier_key", limit: 90, null: false + t.boolean "enabled", default: true, null: false + end + + add_index "thredded_notifications_for_followed_topics", ["user_id", "notifier_key"], name: "thredded_notifications_for_followed_topics_unique", unique: true + + create_table "thredded_notifications_for_private_topics", force: :cascade do |t| + t.integer "user_id", null: false + t.string "notifier_key", limit: 90, null: false + t.boolean "enabled", default: true, null: false + end + + add_index "thredded_notifications_for_private_topics", ["user_id", "notifier_key"], name: "thredded_notifications_for_private_topics_unique", unique: true + + create_table "thredded_post_moderation_records", force: :cascade do |t| + t.integer "post_id" + t.integer "messageboard_id" + t.text "post_content", limit: 65535 + t.integer "post_user_id" + t.text "post_user_name" + t.integer "moderator_id" + t.integer "moderation_state", null: false + t.integer "previous_moderation_state", null: false + t.datetime "created_at", null: false + end + + add_index "thredded_post_moderation_records", ["messageboard_id", "created_at"], name: "index_thredded_moderation_records_for_display" + + create_table "thredded_posts", force: :cascade do |t| + t.integer "user_id" + t.text "content", limit: 65535 + t.string "ip", limit: 255 + t.string "source", limit: 255, default: "web" + t.integer "postable_id", null: false + t.integer "messageboard_id", null: false + t.integer "moderation_state", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "thredded_posts", ["messageboard_id"], name: "index_thredded_posts_on_messageboard_id" + add_index "thredded_posts", ["moderation_state", "updated_at"], name: "index_thredded_posts_for_display" + add_index "thredded_posts", ["postable_id"], name: "index_thredded_posts_on_postable_id_and_postable_type" + add_index "thredded_posts", ["user_id"], name: "index_thredded_posts_on_user_id" + + create_table "thredded_private_posts", force: :cascade do |t| + t.integer "user_id" + t.text "content", limit: 65535 + t.integer "postable_id", null: false + t.string "ip", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "thredded_private_topics", force: :cascade do |t| + t.integer "user_id" + t.integer "last_user_id" + t.string "title", limit: 255, null: false + t.string "slug", limit: 191, null: false + t.integer "posts_count", default: 0 + t.string "hash_id", limit: 191, null: false + t.datetime "last_post_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "thredded_private_topics", ["hash_id"], name: "index_thredded_private_topics_on_hash_id" + add_index "thredded_private_topics", ["slug"], name: "index_thredded_private_topics_on_slug" + + create_table "thredded_private_users", force: :cascade do |t| + t.integer "private_topic_id" + t.integer "user_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "thredded_private_users", ["private_topic_id"], name: "index_thredded_private_users_on_private_topic_id" + add_index "thredded_private_users", ["user_id"], name: "index_thredded_private_users_on_user_id" + + create_table "thredded_topic_categories", force: :cascade do |t| + t.integer "topic_id", null: false + t.integer "category_id", null: false + end + + add_index "thredded_topic_categories", ["category_id"], name: "index_thredded_topic_categories_on_category_id" + add_index "thredded_topic_categories", ["topic_id"], name: "index_thredded_topic_categories_on_topic_id" + + create_table "thredded_topics", force: :cascade do |t| + t.integer "user_id" + t.integer "last_user_id" + t.string "title", limit: 255, null: false + t.string "slug", limit: 191, null: false + t.integer "messageboard_id", null: false + t.integer "posts_count", default: 0, null: false + t.boolean "sticky", default: false, null: false + t.boolean "locked", default: false, null: false + t.string "hash_id", limit: 191, null: false + t.string "type", limit: 191 + t.integer "moderation_state", null: false + t.datetime "last_post_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "thredded_topics", ["hash_id"], name: "index_thredded_topics_on_hash_id" + add_index "thredded_topics", ["messageboard_id"], name: "index_thredded_topics_on_messageboard_id" + add_index "thredded_topics", ["moderation_state", "sticky", "updated_at"], name: "index_thredded_topics_for_display" + add_index "thredded_topics", ["slug"], name: "index_thredded_topics_on_slug", unique: true + add_index "thredded_topics", ["user_id"], name: "index_thredded_topics_on_user_id" + + create_table "thredded_user_details", force: :cascade do |t| + t.integer "user_id", null: false + t.datetime "latest_activity_at" + t.integer "posts_count", default: 0 + t.integer "topics_count", default: 0 + t.datetime "last_seen_at" + t.integer "moderation_state", default: 0, null: false + t.datetime "moderation_state_changed_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "thredded_user_details", ["latest_activity_at"], name: "index_thredded_user_details_on_latest_activity_at" + add_index "thredded_user_details", ["moderation_state", "moderation_state_changed_at"], name: "index_thredded_user_details_for_moderations" + add_index "thredded_user_details", ["user_id"], name: "index_thredded_user_details_on_user_id" + + create_table "thredded_user_messageboard_preferences", force: :cascade do |t| + t.integer "user_id", null: false + t.integer "messageboard_id", null: false + t.boolean "follow_topics_on_mention", default: true, null: false + t.boolean "auto_follow_topics", default: false, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "thredded_user_messageboard_preferences", ["user_id", "messageboard_id"], name: "thredded_user_messageboard_preferences_user_id_messageboard_id", unique: true + + create_table "thredded_user_post_notifications", force: :cascade do |t| + t.integer "user_id", null: false + t.integer "post_id", null: false + t.datetime "notified_at", null: false + end + + add_index "thredded_user_post_notifications", ["post_id"], name: "index_thredded_user_post_notifications_on_post_id" + add_index "thredded_user_post_notifications", ["user_id", "post_id"], name: "index_thredded_user_post_notifications_on_user_id_and_post_id", unique: true + + create_table "thredded_user_preferences", force: :cascade do |t| + t.integer "user_id", null: false + t.boolean "follow_topics_on_mention", default: true, null: false + t.boolean "auto_follow_topics", default: false, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "thredded_user_preferences", ["user_id"], name: "index_thredded_user_preferences_on_user_id" + + create_table "thredded_user_private_topic_read_states", force: :cascade do |t| + t.integer "user_id", null: false + t.integer "postable_id", null: false + t.integer "page", default: 1, null: false + t.datetime "read_at", null: false + end + + add_index "thredded_user_private_topic_read_states", ["user_id", "postable_id"], name: "thredded_user_private_topic_read_states_user_postable", unique: true + + create_table "thredded_user_topic_follows", force: :cascade do |t| + t.integer "user_id", null: false + t.integer "topic_id", null: false + t.datetime "created_at", null: false + t.integer "reason", limit: 1 + end + + add_index "thredded_user_topic_follows", ["user_id", "topic_id"], name: "thredded_user_topic_follows_user_topic", unique: true + + create_table "thredded_user_topic_read_states", force: :cascade do |t| + t.integer "user_id", null: false + t.integer "postable_id", null: false + t.integer "page", default: 1, null: false + t.datetime "read_at", null: false + end + + add_index "thredded_user_topic_read_states", ["user_id", "postable_id"], name: "thredded_user_topic_read_states_user_postable", unique: true + create_table "universes", force: :cascade do |t| t.string "name", null: false t.text "description" diff --git a/test/fixtures/content_change_events.yml b/test/fixtures/content_change_events.yml new file mode 100644 index 00000000..13c66568 --- /dev/null +++ b/test/fixtures/content_change_events.yml @@ -0,0 +1,15 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + user_id: + changed_fields: MyText + content_id: 1 + content_type: MyString + action: MyString + +two: + user_id: + changed_fields: MyText + content_id: 1 + content_type: MyString + action: MyString diff --git a/test/models/content_change_event_test.rb b/test/models/content_change_event_test.rb new file mode 100644 index 00000000..214b7a98 --- /dev/null +++ b/test/models/content_change_event_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class ContentChangeEventTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end