Skip to content
Snippets Groups Projects
Commit 79b79b75 authored by Arnaud Levy's avatar Arnaud Levy
Browse files

website pages draft

parent 64ae3950
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,9 @@ fr:
communication/website:
one: Site Web
other: Sites Web
communication/website/page:
one: Page
other: Pages
attributes:
communication/website:
name: Nom
......
......@@ -12,5 +12,5 @@ Rails.application.routes.draw do
draw 'communication'
draw 'administration'
root to: 'home#index'
root to: 'communication/website/pages#index'
end
namespace :communication do
resources :websites
resources :websites do
resources :pages, controller: 'website/pages'
end
end
namespace :communication do
resources :websites
root to: 'websites#index'
namespace :website do
resources :pages, only: [:index, :show]
end
end
namespace :education do
resources :programs
root to: 'programs#index'
resources :programs, only: [:index, :show]
end
class CreateCommunicationWebsitePages < ActiveRecord::Migration[6.1]
def change
create_table :communication_website_pages, id: :uuid do |t|
t.references :university, null: false, foreign_key: true, type: :uuid
t.references :communication_website, null: false, foreign_key: true, type: :uuid
t.string :title
t.text :description
t.string :slug
t.text :path
t.datetime :published_at
t.references :parent, foreign_key: {to_table: :communication_website_pages}, type: :uuid
t.integer :position, default: 0, null: false
t.references :about, polymorphic: true, type: :uuid
t.timestamps
end
end
end
......@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2021_08_17_125119) do
ActiveRecord::Schema.define(version: 2021_08_21_121439) do
# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
......@@ -38,6 +38,26 @@ ActiveRecord::Schema.define(version: 2021_08_17_125119) do
t.index ["criterion_id"], name: "index_administration_qualiopi_indicators_on_criterion_id"
end
create_table "communication_website_pages", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.uuid "university_id", null: false
t.uuid "communication_website_id", null: false
t.string "title"
t.text "description"
t.string "slug"
t.text "path"
t.datetime "published_at"
t.uuid "parent_id"
t.integer "position", default: 0, null: false
t.string "about_type"
t.uuid "about_id"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["about_type", "about_id"], name: "index_communication_website_pages_on_about"
t.index ["communication_website_id"], name: "index_communication_website_pages_on_communication_website_id"
t.index ["parent_id"], name: "index_communication_website_pages_on_parent_id"
t.index ["university_id"], name: "index_communication_website_pages_on_university_id"
end
create_table "communication_websites", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.uuid "university_id", null: false
t.string "name"
......@@ -147,6 +167,9 @@ ActiveRecord::Schema.define(version: 2021_08_17_125119) do
end
add_foreign_key "administration_qualiopi_indicators", "administration_qualiopi_criterions", column: "criterion_id"
add_foreign_key "communication_website_pages", "communication_website_pages", column: "parent_id"
add_foreign_key "communication_website_pages", "communication_websites"
add_foreign_key "communication_website_pages", "universities"
add_foreign_key "communication_websites", "universities"
add_foreign_key "education_programs", "universities"
add_foreign_key "research_journal_articles", "research_journal_volumes"
......
require "test_helper"
class Communication::Website::PagesControllerTest < ActionDispatch::IntegrationTest
setup do
@communication_website_page = communication_website_pages(:one)
end
test "should get index" do
get communication_website_pages_url
assert_response :success
end
test "should get new" do
get new_communication_website_page_url
assert_response :success
end
test "should create communication_website_page" do
assert_difference('Communication::Website::Page.count') do
post communication_website_pages_url, params: { communication_website_page: { about_id: @communication_website_page.about_id, communication_website_id: @communication_website_page.communication_website_id, description: @communication_website_page.description, kind: @communication_website_page.kind, title: @communication_website_page.title, university_id: @communication_website_page.university_id } }
end
assert_redirected_to communication_website_page_url(Communication::Website::Page.last)
end
test "should show communication_website_page" do
get communication_website_page_url(@communication_website_page)
assert_response :success
end
test "should get edit" do
get edit_communication_website_page_url(@communication_website_page)
assert_response :success
end
test "should update communication_website_page" do
patch communication_website_page_url(@communication_website_page), params: { communication_website_page: { about_id: @communication_website_page.about_id, communication_website_id: @communication_website_page.communication_website_id, description: @communication_website_page.description, kind: @communication_website_page.kind, title: @communication_website_page.title, university_id: @communication_website_page.university_id } }
assert_redirected_to communication_website_page_url(@communication_website_page)
end
test "should destroy communication_website_page" do
assert_difference('Communication::Website::Page.count', -1) do
delete communication_website_page_url(@communication_website_page)
end
assert_redirected_to communication_website_pages_url
end
end
# == Schema Information
#
# Table name: communication_website_pages
#
# id :uuid not null, primary key
# about_type :string
# description :text
# path :text
# position :integer default(0), not null
# published_at :datetime
# slug :string
# title :string
# created_at :datetime not null
# updated_at :datetime not null
# about_id :uuid
# communication_website_id :uuid not null
# parent_id :uuid
# university_id :uuid not null
#
# Indexes
#
# index_communication_website_pages_on_about (about_type,about_id)
# index_communication_website_pages_on_communication_website_id (communication_website_id)
# index_communication_website_pages_on_parent_id (parent_id)
# index_communication_website_pages_on_university_id (university_id)
#
# Foreign Keys
#
# fk_rails_... (communication_website_id => communication_websites.id)
# fk_rails_... (parent_id => communication_website_pages.id)
# fk_rails_... (university_id => universities.id)
#
one:
university: one
communication_website: one
title: MyString
description: MyText
kind: 1
about: one
two:
university: two
communication_website: two
title: MyString
description: MyText
kind: 1
about: two
# == Schema Information
#
# Table name: communication_website_pages
#
# id :uuid not null, primary key
# about_type :string
# description :text
# path :text
# position :integer default(0), not null
# published_at :datetime
# slug :string
# title :string
# created_at :datetime not null
# updated_at :datetime not null
# about_id :uuid
# communication_website_id :uuid not null
# parent_id :uuid
# university_id :uuid not null
#
# Indexes
#
# index_communication_website_pages_on_about (about_type,about_id)
# index_communication_website_pages_on_communication_website_id (communication_website_id)
# index_communication_website_pages_on_parent_id (parent_id)
# index_communication_website_pages_on_university_id (university_id)
#
# Foreign Keys
#
# fk_rails_... (communication_website_id => communication_websites.id)
# fk_rails_... (parent_id => communication_website_pages.id)
# fk_rails_... (university_id => universities.id)
#
require "test_helper"
class Communication::Website::PageTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
require "application_system_test_case"
class Communication::Website::PagesTest < ApplicationSystemTestCase
setup do
@communication_website_page = communication_website_pages(:one)
end
test "visiting the index" do
visit communication_website_pages_url
assert_selector "h1", text: "Communication/Website/Pages"
end
test "creating a Page" do
visit communication_website_pages_url
click_on "New Communication/Website/Page"
fill_in "About", with: @communication_website_page.about_id
fill_in "Communication website", with: @communication_website_page.communication_website_id
fill_in "Description", with: @communication_website_page.description
fill_in "Kind", with: @communication_website_page.kind
fill_in "Title", with: @communication_website_page.title
fill_in "University", with: @communication_website_page.university_id
click_on "Create Page"
assert_text "Page was successfully created"
click_on "Back"
end
test "updating a Page" do
visit communication_website_pages_url
click_on "Edit", match: :first
fill_in "About", with: @communication_website_page.about_id
fill_in "Communication website", with: @communication_website_page.communication_website_id
fill_in "Description", with: @communication_website_page.description
fill_in "Kind", with: @communication_website_page.kind
fill_in "Title", with: @communication_website_page.title
fill_in "University", with: @communication_website_page.university_id
click_on "Update Page"
assert_text "Page was successfully updated"
click_on "Back"
end
test "destroying a Page" do
visit communication_website_pages_url
page.accept_confirm do
click_on "Destroy", match: :first
end
assert_text "Page was successfully destroyed"
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment