Add subscription model and link it to RFC

This commit is contained in:
Maximilian Grundke
2017-09-06 15:16:47 +02:00
parent f628774995
commit 5aa9edb209
6 changed files with 81 additions and 1 deletions

View File

@ -5,6 +5,8 @@ class RequestForComment < ActiveRecord::Base
belongs_to :file, class_name: 'CodeOcean::File'
has_many :comments, through: :submission
has_many :subscriptions
has_many :subscribers, through: :subscriptions, source: :user, source_type: ExternalUser
scope :unsolved, -> { where(solved: [false, nil]) }

View File

@ -0,0 +1,4 @@
class Subscription < ActiveRecord::Base
belongs_to :user, polymorphic: true
belongs_to :request_for_comment
end

View File

@ -0,0 +1,11 @@
class CreateSubscriptions < ActiveRecord::Migration
def change
create_table :subscriptions do |t|
t.belongs_to :user, polymorphic: true
t.references :request_for_comment
t.string :type
t.timestamps null: false
end
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170608141612) do
ActiveRecord::Schema.define(version: 20170906124500) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -47,6 +47,30 @@ ActiveRecord::Schema.define(version: 20170608141612) do
t.string "oauth_secret", limit: 255
end
create_table "error_template_attributes", force: :cascade do |t|
t.string "key"
t.string "regex"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.text "description"
t.boolean "important"
end
create_table "error_template_attributes_templates", id: false, force: :cascade do |t|
t.integer "error_template_id", null: false
t.integer "error_template_attribute_id", null: false
end
create_table "error_templates", force: :cascade do |t|
t.integer "execution_environment_id"
t.string "name"
t.string "signature"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.text "description"
t.text "hint"
end
create_table "errors", force: :cascade do |t|
t.integer "execution_environment_id"
t.text "message"
@ -268,6 +292,22 @@ ActiveRecord::Schema.define(version: 20170608141612) do
t.datetime "updated_at"
end
create_table "structured_error_attributes", force: :cascade do |t|
t.integer "structured_error_id"
t.integer "error_template_attribute_id"
t.string "value"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "match"
end
create_table "structured_errors", force: :cascade do |t|
t.integer "error_template_id"
t.integer "file_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "submissions", force: :cascade do |t|
t.integer "exercise_id"
t.float "score"
@ -281,6 +321,15 @@ ActiveRecord::Schema.define(version: 20170608141612) do
add_index "submissions", ["exercise_id"], name: "index_submissions_on_exercise_id", using: :btree
add_index "submissions", ["user_id"], name: "index_submissions_on_user_id", using: :btree
create_table "subscriptions", force: :cascade do |t|
t.integer "user_id"
t.string "user_type"
t.integer "request_for_comment_id"
t.string "type"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "tags", force: :cascade do |t|
t.string "name", null: false
t.datetime "created_at"

View File

@ -0,0 +1,7 @@
FactoryGirl.define do
factory :subscription do
user nil
request_for_comments nil
type ""
end
end

View File

@ -0,0 +1,7 @@
require 'test_helper'
class SubscriptionTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end