Compare commits
3 Commits
master
...
remove-doc
| Author | SHA1 | Date |
|---|---|---|
|
|
e16c3b4308 | 4 years ago |
|
|
aeac325b2b | 4 years ago |
|
|
5704d93544 | 4 years ago |
20 changed files with 40 additions and 131 deletions
@ -1,52 +0,0 @@
|
||||
class Jurisprudence::DoctrinesController < ApplicationController |
||||
load_and_authorize_resource :jurisprudence, class: "Cdao::Jurisprudence" |
||||
load_and_authorize_resource :doctrine, class: "Doctrine", through: :jurisprudence |
||||
|
||||
def create |
||||
attrs = resource_params.to_unsafe_h.deep_symbolize_keys |
||||
subject_ids = attrs.delete(:subject_ids) |
||||
|
||||
@doctrine = @jurisprudence.doctrines.new(attrs) |
||||
|
||||
respond_to do |format| |
||||
if @doctrine.save |
||||
@doctrine.subject_ids = subject_ids if subject_ids.present? |
||||
|
||||
format.html { redirect_to document_doctrine_path(@jurisprudence, @doctrine), notice: "Doctrine was successfully created." } |
||||
else |
||||
format.html { redirect_to document_doctrine_path(@jurisprudence) } |
||||
end |
||||
end |
||||
end |
||||
|
||||
def update |
||||
attrs = resource_params.to_unsafe_h.deep_symbolize_keys |
||||
subject_ids = attrs.delete(:subject_ids) |
||||
|
||||
respond_to do |format| |
||||
if @doctrine.update(attrs) |
||||
@doctrine.subject_ids = subject_ids if subject_ids.present? |
||||
|
||||
format.html { redirect_to document_doctrine_path(@jurisprudence, @doctrine), notice: "Doctrine was successfully updated." } |
||||
else |
||||
format.html { redirect_to document_doctrine_path(@jurisprudence) } |
||||
end |
||||
end |
||||
end |
||||
|
||||
def destroy |
||||
respond_to do |format| |
||||
if @doctrine.destroy |
||||
format.html { redirect_to document_path(@jurisprudence), notice: "Doctrine was successfully destroyed." } |
||||
else |
||||
format.html { redirect_to document_path(@jurisprudence), alert: @doctrine.errors.full_messages } |
||||
end |
||||
end |
||||
end |
||||
|
||||
private |
||||
|
||||
def resource_params |
||||
params.permit(:content, subject_ids: []) |
||||
end |
||||
end |
||||
@ -0,0 +1,6 @@
|
||||
class DoctrineJurisprudence < ApplicationRecord |
||||
acts_as_list column: :rank, scope: %i[doctrine_id] |
||||
|
||||
belongs_to :doctrine, optional: false |
||||
belongs_to :jurisprudence, class_name: "Cdao::Jurisprudence", optional: false |
||||
end |
||||
@ -0,0 +1,15 @@
|
||||
class CreateDoctrineJurisprudences < ActiveRecord::Migration[6.1] |
||||
def change |
||||
create_table :doctrine_jurisprudences do |t| |
||||
t.references :doctrine, null: false |
||||
t.references :jurisprudence, null: false |
||||
t.integer :rank, null: false, default: 1 |
||||
|
||||
t.timestamps |
||||
end |
||||
|
||||
add_index :doctrine_jurisprudences, %i[doctrine_id jurisprudence_id], |
||||
name: "index_doctrine_jurisprudences_uniqueness", |
||||
unique: true |
||||
end |
||||
end |
||||
@ -0,0 +1,6 @@
|
||||
class RemoveDocumentTypeAndDocumentIdInDoctrines < ActiveRecord::Migration[6.1] |
||||
def up |
||||
remove_column :doctrines, :document_type, :string |
||||
remove_column :doctrines, :document_id, :integer |
||||
end |
||||
end |
||||
@ -1,5 +0,0 @@
|
||||
require "test_helper" |
||||
|
||||
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase |
||||
driven_by :selenium, using: :chrome, screen_size: [1400, 1400] |
||||
end |
||||
@ -1,11 +0,0 @@
|
||||
require "test_helper" |
||||
|
||||
class ApplicationCable::ConnectionTest < ActionCable::Connection::TestCase |
||||
# test "connects with cookies" do |
||||
# cookies.signed[:user_id] = 42 |
||||
# |
||||
# connect |
||||
# |
||||
# assert_equal connection.user_id, "42" |
||||
# end |
||||
end |
||||
@ -1,13 +0,0 @@
|
||||
ENV['RAILS_ENV'] ||= 'test' |
||||
require_relative "../config/environment" |
||||
require "rails/test_help" |
||||
|
||||
class ActiveSupport::TestCase |
||||
# Run tests in parallel with specified workers |
||||
parallelize(workers: :number_of_processors) |
||||
|
||||
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. |
||||
fixtures :all |
||||
|
||||
# Add more helper methods to be used by all tests here... |
||||
end |
||||
Loading…
Reference in new issue