Commit bb468849 authored by Jan Provaznik's avatar Jan Provaznik

Drop preparation for group requirements

Although it would be handy to prepare model also
for group requirements, for MVC these won't be supported
so to avoid any confusion the model supports
only project requirements.
parent 734c5e6a
...@@ -9,8 +9,7 @@ class CreateRequirements < ActiveRecord::Migration[6.0] ...@@ -9,8 +9,7 @@ class CreateRequirements < ActiveRecord::Migration[6.0]
create_table :requirements do |t| create_table :requirements do |t|
t.integer :state, limit: 2, default: 1, null: false t.integer :state, limit: 2, default: 1, null: false
t.integer :iid, null: false t.integer :iid, null: false
t.references :project, index: true, foreign_key: { on_delete: :cascade } t.references :project, null: false, index: true, foreign_key: { on_delete: :cascade }
t.references :group, index: true, foreign_key: { to_table: :namespaces, on_delete: :cascade }
t.references :author, index: true, foreign_key: { to_table: :users, on_delete: :nullify } t.references :author, index: true, foreign_key: { to_table: :users, on_delete: :nullify }
t.timestamps_with_timezone null: false t.timestamps_with_timezone null: false
t.string :title, limit: 255, null: false t.string :title, limit: 255, null: false
...@@ -21,7 +20,6 @@ class CreateRequirements < ActiveRecord::Migration[6.0] ...@@ -21,7 +20,6 @@ class CreateRequirements < ActiveRecord::Migration[6.0]
t.index :created_at t.index :created_at
t.index :updated_at t.index :updated_at
t.index %w(project_id iid), name: 'index_requirements_on_project_id_and_iid', where: 'project_id IS NOT NULL', unique: true, using: :btree t.index %w(project_id iid), name: 'index_requirements_on_project_id_and_iid', where: 'project_id IS NOT NULL', unique: true, using: :btree
t.index %w(group_id iid), name: 'index_requirements_on_group_id_and_iid', where: 'group_id IS NOT NULL', unique: true, using: :btree
end end
end end
end end
...@@ -3725,8 +3725,7 @@ ActiveRecord::Schema.define(version: 2020_02_27_165129) do ...@@ -3725,8 +3725,7 @@ ActiveRecord::Schema.define(version: 2020_02_27_165129) do
create_table "requirements", force: :cascade do |t| create_table "requirements", force: :cascade do |t|
t.integer "state", limit: 2, default: 1, null: false t.integer "state", limit: 2, default: 1, null: false
t.integer "iid", null: false t.integer "iid", null: false
t.bigint "project_id" t.bigint "project_id", null: false
t.bigint "group_id"
t.bigint "author_id" t.bigint "author_id"
t.datetime_with_timezone "created_at", null: false t.datetime_with_timezone "created_at", null: false
t.datetime_with_timezone "updated_at", null: false t.datetime_with_timezone "updated_at", null: false
...@@ -3734,8 +3733,6 @@ ActiveRecord::Schema.define(version: 2020_02_27_165129) do ...@@ -3734,8 +3733,6 @@ ActiveRecord::Schema.define(version: 2020_02_27_165129) do
t.text "title_html" t.text "title_html"
t.index ["author_id"], name: "index_requirements_on_author_id" t.index ["author_id"], name: "index_requirements_on_author_id"
t.index ["created_at"], name: "index_requirements_on_created_at" t.index ["created_at"], name: "index_requirements_on_created_at"
t.index ["group_id", "iid"], name: "index_requirements_on_group_id_and_iid", unique: true, where: "(group_id IS NOT NULL)"
t.index ["group_id"], name: "index_requirements_on_group_id"
t.index ["project_id", "iid"], name: "index_requirements_on_project_id_and_iid", unique: true, where: "(project_id IS NOT NULL)" t.index ["project_id", "iid"], name: "index_requirements_on_project_id_and_iid", unique: true, where: "(project_id IS NOT NULL)"
t.index ["project_id"], name: "index_requirements_on_project_id" t.index ["project_id"], name: "index_requirements_on_project_id"
t.index ["state"], name: "index_requirements_on_state" t.index ["state"], name: "index_requirements_on_state"
...@@ -5017,7 +5014,6 @@ ActiveRecord::Schema.define(version: 2020_02_27_165129) do ...@@ -5017,7 +5014,6 @@ ActiveRecord::Schema.define(version: 2020_02_27_165129) do
add_foreign_key "releases", "users", column: "author_id", name: "fk_8e4456f90f", on_delete: :nullify add_foreign_key "releases", "users", column: "author_id", name: "fk_8e4456f90f", on_delete: :nullify
add_foreign_key "remote_mirrors", "projects", name: "fk_43a9aa4ca8", on_delete: :cascade add_foreign_key "remote_mirrors", "projects", name: "fk_43a9aa4ca8", on_delete: :cascade
add_foreign_key "repository_languages", "projects", on_delete: :cascade add_foreign_key "repository_languages", "projects", on_delete: :cascade
add_foreign_key "requirements", "namespaces", column: "group_id", on_delete: :cascade
add_foreign_key "requirements", "projects", on_delete: :cascade add_foreign_key "requirements", "projects", on_delete: :cascade
add_foreign_key "requirements", "users", column: "author_id", on_delete: :nullify add_foreign_key "requirements", "users", column: "author_id", on_delete: :nullify
add_foreign_key "resource_label_events", "epics", on_delete: :cascade add_foreign_key "resource_label_events", "epics", on_delete: :cascade
......
...@@ -17,7 +17,6 @@ module EE ...@@ -17,7 +17,6 @@ module EE
add_authentication_token_field :saml_discovery_token, unique: false, token_generator: -> { Devise.friendly_token(8) } add_authentication_token_field :saml_discovery_token, unique: false, token_generator: -> { Devise.friendly_token(8) }
has_many :epics has_many :epics
has_many :requirements
has_one :saml_provider has_one :saml_provider
has_many :ip_restrictions, autosave: true has_many :ip_restrictions, autosave: true
......
...@@ -7,15 +7,9 @@ class Requirement < ApplicationRecord ...@@ -7,15 +7,9 @@ class Requirement < ApplicationRecord
belongs_to :author, class_name: 'User' belongs_to :author, class_name: 'User'
belongs_to :project belongs_to :project
belongs_to :group
validates :author, :project, :title, presence: true validates :author, :project, :title, presence: true
# For MVC, we allow only project-scoped requirements,
# but we already know that in the next iteration we will
# need also group-scoped requirements
validates :group, absence: true
validates :title, length: { maximum: Issuable::TITLE_LENGTH_MAX } validates :title, length: { maximum: Issuable::TITLE_LENGTH_MAX }
validates :title_html, length: { maximum: Issuable::TITLE_HTML_LENGTH_MAX }, allow_blank: true validates :title_html, length: { maximum: Issuable::TITLE_HTML_LENGTH_MAX }, allow_blank: true
......
...@@ -4,14 +4,12 @@ require 'spec_helper' ...@@ -4,14 +4,12 @@ require 'spec_helper'
describe Requirement do describe Requirement do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group) } let_it_be(:project) { create(:project) }
let_it_be(:project) { create(:project, group: group) }
describe 'associations' do describe 'associations' do
subject { build(:requirement) } subject { build(:requirement) }
it { is_expected.to belong_to(:author).class_name('User') } it { is_expected.to belong_to(:author).class_name('User') }
it { is_expected.to belong_to(:group) }
it { is_expected.to belong_to(:project) } it { is_expected.to belong_to(:project) }
end end
...@@ -21,7 +19,6 @@ describe Requirement do ...@@ -21,7 +19,6 @@ describe Requirement do
it { is_expected.to validate_presence_of(:project) } it { is_expected.to validate_presence_of(:project) }
it { is_expected.to validate_presence_of(:author) } it { is_expected.to validate_presence_of(:author) }
it { is_expected.to validate_presence_of(:title) } it { is_expected.to validate_presence_of(:title) }
it { is_expected.to validate_absence_of(:group) }
it { is_expected.to validate_length_of(:title).is_at_most(::Issuable::TITLE_LENGTH_MAX) } it { is_expected.to validate_length_of(:title).is_at_most(::Issuable::TITLE_LENGTH_MAX) }
it { is_expected.to validate_length_of(:title_html).is_at_most(::Issuable::TITLE_HTML_LENGTH_MAX) } it { is_expected.to validate_length_of(:title_html).is_at_most(::Issuable::TITLE_HTML_LENGTH_MAX) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment