DraftVersion base model and very basic admin pages
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
class Admin::Legislation::DraftVersionsController < Admin::Legislation::BaseController
|
||||
load_and_authorize_resource :process, class: "Legislation::Process"
|
||||
load_and_authorize_resource :draft_version, class: "Legislation::DraftVersion", through: :process
|
||||
|
||||
def index
|
||||
@draft_versions = @process.draft_versions
|
||||
end
|
||||
|
||||
def create
|
||||
@draft_version = @process.draft_versions.new(draft_version_params)
|
||||
if @process.save
|
||||
redirect_to admin_legislation_process_draft_versions_path
|
||||
else
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
if @draft_version.update(draft_version_params)
|
||||
redirect_to admin_legislation_process_draft_versions_path
|
||||
else
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@draft_version.destroy
|
||||
redirect_to admin_legislation_process_draft_versions_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def draft_version_params
|
||||
params.require(:legislation_draft_version).permit(
|
||||
:legislation_process_id,
|
||||
:title,
|
||||
:changelog,
|
||||
:status,
|
||||
:final_version,
|
||||
:body
|
||||
)
|
||||
end
|
||||
end
|
||||
@@ -17,7 +17,6 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll
|
||||
end
|
||||
|
||||
def update
|
||||
@process.assign_attributes(process_params)
|
||||
if @process.update(process_params)
|
||||
redirect_to admin_legislation_processes_path
|
||||
else
|
||||
|
||||
@@ -45,6 +45,7 @@ module Abilities
|
||||
can [:search, :edit, :update, :create, :index, :destroy], Banner
|
||||
|
||||
can [:manage], ::Legislation::Process
|
||||
can [:manage], ::Legislation::DraftVersion
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
12
app/models/legislation/draft_version.rb
Normal file
12
app/models/legislation/draft_version.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class Legislation::DraftVersion < ActiveRecord::Base
|
||||
VALID_STATUSES = %w(draft published)
|
||||
|
||||
acts_as_paranoid column: :hidden_at
|
||||
include ActsAsParanoidAliases
|
||||
|
||||
belongs_to :process, class_name: 'Legislation::Process', foreign_key: 'legislation_process_id'
|
||||
|
||||
validates :title, presence: true
|
||||
validates :body, presence: true
|
||||
validates :status, presence: true, inclusion: { in: VALID_STATUSES }
|
||||
end
|
||||
@@ -2,6 +2,8 @@ class Legislation::Process < ActiveRecord::Base
|
||||
acts_as_paranoid column: :hidden_at
|
||||
include ActsAsParanoidAliases
|
||||
|
||||
has_many :draft_versions, class_name: 'Legislation::DraftVersion', foreign_key: 'legislation_process_id'
|
||||
|
||||
validates :title, presence: true
|
||||
validates :description, presence: true
|
||||
validates :target, presence: true
|
||||
|
||||
72
app/views/admin/legislation/draft_versions/_form.html.erb
Normal file
72
app/views/admin/legislation/draft_versions/_form.html.erb
Normal file
@@ -0,0 +1,72 @@
|
||||
<%= form_for [:admin, @process, @draft_version], url: url do |f| %>
|
||||
|
||||
<% if @draft_version.errors.any? %>
|
||||
|
||||
<div id="error_explanation" data-alert class="callout alert" data-closable>
|
||||
<button class="close-button" aria-label="<%= t("application.close") %>" type="button" data-close>
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
|
||||
<strong>
|
||||
<%= @draft_version.errors.count %>
|
||||
<%= t("admin.legislation.draft_versions.errors.form.error", count: @process.errors.count) %>
|
||||
</strong>
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
|
||||
<div class="row">
|
||||
<div class="small-12 medium-4 column">
|
||||
<%= f.label :title %>
|
||||
</div>
|
||||
<div class="small-12 medium-8 column">
|
||||
<%= f.text_field :title, label: false %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="small-12 medium-4 column">
|
||||
<%= f.label :changelog %>
|
||||
</div>
|
||||
<div class="small-12 medium-8 column">
|
||||
<%= f.text_area :changelog, label: false, rows: 5 %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="small-12 medium-4 column">
|
||||
<%= f.label :status %>
|
||||
</div>
|
||||
<div class="small-12 medium-8 column">
|
||||
<% ::Legislation::DraftVersion::VALID_STATUSES.each do |status| %>
|
||||
<%= f.radio_button :status, status, label: false %>
|
||||
<%= f.label t("admin.legislation.draft_versions.statuses.#{status}") %>
|
||||
<br/>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="small-12 medium-4 column">
|
||||
<%= f.label :final_version %>
|
||||
</div>
|
||||
<div class="small-12 medium-8 column">
|
||||
<%= f.check_box :final_version, label: false %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="small-12 medium-4 column">
|
||||
<%= f.label :body %>
|
||||
</div>
|
||||
<div class="small-12 medium-8 column">
|
||||
<%= f.text_area :body, label: false, rows: 15 %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="actions small-12 medium-3 column">
|
||||
<%= f.submit(class: "button expanded", value: t("admin.legislation.draft_versions.#{admin_submit_action(@draft_version)}.submit_button")) %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
21
app/views/admin/legislation/draft_versions/edit.html.erb
Normal file
21
app/views/admin/legislation/draft_versions/edit.html.erb
Normal file
@@ -0,0 +1,21 @@
|
||||
<div class="legislation-draft-versions-index row">
|
||||
<div class="small-12 column">
|
||||
<%= link_to admin_legislation_processes_path, class: "back" do %>
|
||||
<span class="icon-angle-left"></span>
|
||||
<%= t("admin.legislation.draft_versions.edit.back") %>
|
||||
<% end %>
|
||||
|
||||
<h1><%= @process.title %></h1>
|
||||
|
||||
<%= render 'admin/legislation/processes/subnav', process: @process, active: 'draft_versions' %>
|
||||
|
||||
<h3><%= @draft_version.title %></h3>
|
||||
|
||||
<%= render 'form', url: admin_legislation_process_draft_version_path(@process, @draft_version) %>
|
||||
|
||||
<%= link_to t("admin.legislation.processes.index.delete"), admin_legislation_process_draft_version_path(@process, @draft_version),
|
||||
method: :delete,
|
||||
class: 'button hollow alert' %>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
38
app/views/admin/legislation/draft_versions/index.html.erb
Normal file
38
app/views/admin/legislation/draft_versions/index.html.erb
Normal file
@@ -0,0 +1,38 @@
|
||||
<div class="legislation-draft-versions-index row">
|
||||
<div class="small-12 column">
|
||||
<%= link_to admin_legislation_processes_path, class: "back" do %>
|
||||
<span class="icon-angle-left"></span>
|
||||
<%= t("admin.legislation.processes.edit.back") %>
|
||||
<% end %>
|
||||
|
||||
<h1><%= @process.title %></h1>
|
||||
|
||||
<%= render 'admin/legislation/processes/subnav', process: @process, active: 'draft_versions' %>
|
||||
|
||||
<%= link_to t("admin.legislation.draft_versions.index.create"),
|
||||
new_admin_legislation_process_draft_version_path, class: "button float-right" %>
|
||||
|
||||
<h3><%= t("admin.legislation.draft_versions.index.title") %></h3>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th><%= t("admin.legislation.draft_versions.table.title") %></th>
|
||||
<th><%= t("admin.legislation.draft_versions.table.created_at") %></th>
|
||||
<th><%= t("admin.legislation.draft_versions.table.status") %></th>
|
||||
<th><%= t("admin.legislation.draft_versions.table.comments") %></th>
|
||||
<th><%= t("admin.legislation.draft_versions.table.final_version") %></th>
|
||||
</tr>
|
||||
<% @process.draft_versions.each do |draft_version| %>
|
||||
<tr id="<%= dom_id(draft_version) %>">
|
||||
<td>
|
||||
<%= link_to draft_version.title, edit_admin_legislation_process_draft_version_path(@process, draft_version) %>
|
||||
</td>
|
||||
<td><%= draft_version.created_at.to_date %></td>
|
||||
<td><%= draft_version.status %></td>
|
||||
<td><%#= draft_version.comments %></td>
|
||||
<td><%= draft_version.final_version %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
17
app/views/admin/legislation/draft_versions/new.html.erb
Normal file
17
app/views/admin/legislation/draft_versions/new.html.erb
Normal file
@@ -0,0 +1,17 @@
|
||||
<div class="legislation-draft-versions-index row">
|
||||
<div class="small-12 column">
|
||||
<%= link_to admin_legislation_processes_path, class: "back" do %>
|
||||
<span class="icon-angle-left"></span>
|
||||
<%= t("admin.legislation.draft_versions.new.back") %>
|
||||
<% end %>
|
||||
|
||||
<h1><%= @process.title %></h1>
|
||||
|
||||
<%= render 'admin/legislation/processes/subnav', process: @process, active: 'draft_versions' %>
|
||||
|
||||
<h3><%= t("admin.legislation.draft_versions.new.title") %></h3>
|
||||
|
||||
<%= render 'form', url: admin_legislation_process_draft_versions_path(@process) %>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
8
app/views/admin/legislation/processes/_subnav.html.erb
Normal file
8
app/views/admin/legislation/processes/_subnav.html.erb
Normal file
@@ -0,0 +1,8 @@
|
||||
<ul class="menu simple clear">
|
||||
<li <%= "class=active" if active == 'info' %>>
|
||||
<%= link_to t("admin.legislation.processes.subnav.info"), edit_admin_legislation_process_path(process) %>
|
||||
</li>
|
||||
<li <%= "class=active" if active == 'draft_versions' %>>
|
||||
<%= link_to t("admin.legislation.processes.subnav.draft_texts"), admin_legislation_process_draft_versions_path(process) %>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
<h1><%= @process.title %></h1>
|
||||
|
||||
<%= render 'subnav', process: @process, active: 'info' %>
|
||||
|
||||
<%= render "form" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -19,9 +19,6 @@
|
||||
</td>
|
||||
|
||||
<td class="text-right">
|
||||
<%= link_to t("admin.legislation.processes.index.edit"), edit_admin_legislation_process_path(process),
|
||||
class: 'edit-banner button hollow' %>
|
||||
|
||||
<%= link_to t("admin.legislation.processes.index.delete"), admin_legislation_process_path(process),
|
||||
method: :delete,
|
||||
class: 'button hollow alert' %>
|
||||
|
||||
@@ -119,6 +119,7 @@ ignore_unused:
|
||||
- 'admin.activity.show.filter*'
|
||||
- 'admin.legislation.processes.index.filter*'
|
||||
- 'admin.legislation.processes.*.submit_button'
|
||||
- 'admin.legislation.draft_versions.*.submit_button'
|
||||
- 'admin.comments.index.hidden_*'
|
||||
- 'admin.settings.index.features.*'
|
||||
- 'moderation.comments.index.filter*'
|
||||
|
||||
@@ -37,6 +37,9 @@ en:
|
||||
legislation/process:
|
||||
one: "Process"
|
||||
other: "Processes"
|
||||
legislation/draft_versions:
|
||||
one: "Draft version"
|
||||
other: "Draft versions"
|
||||
attributes:
|
||||
comment:
|
||||
body: "Comment"
|
||||
@@ -86,6 +89,12 @@ en:
|
||||
allegations_start_date: Allegations start date
|
||||
allegations_end_date: Allegations end date
|
||||
final_publication_date: Final result publication date
|
||||
legislation/draft_version:
|
||||
title: Version title
|
||||
body: Text
|
||||
changelog: Changes
|
||||
status: Status
|
||||
final_version: Final version
|
||||
errors:
|
||||
models:
|
||||
user:
|
||||
|
||||
@@ -37,6 +37,9 @@ es:
|
||||
legislation/process:
|
||||
one: "Proceso"
|
||||
other: "Procesos"
|
||||
legislation/draft_texts:
|
||||
one: "Borrador"
|
||||
other: "Borradores"
|
||||
attributes:
|
||||
comment:
|
||||
body: "Comentario"
|
||||
@@ -86,6 +89,12 @@ es:
|
||||
allegations_start_date: Fecha de inicio de alegaciones
|
||||
allegations_end_date: Fecha de fin de alegaciones
|
||||
final_publication_date: Fecha de publicación del resultado final
|
||||
legislation/draft_version:
|
||||
title: Título de la version
|
||||
body: Texto
|
||||
changelog: Cambios
|
||||
status: Estado
|
||||
final_version: Versión final
|
||||
errors:
|
||||
models:
|
||||
user:
|
||||
|
||||
@@ -93,7 +93,6 @@ en:
|
||||
index:
|
||||
create: New process
|
||||
delete: Delete
|
||||
edit: Edit
|
||||
title: Legislation processess
|
||||
filters:
|
||||
open: Open
|
||||
@@ -106,6 +105,32 @@ en:
|
||||
submit_button: Create process
|
||||
process:
|
||||
title: Collaborative legislation process title
|
||||
subnav:
|
||||
info: Information
|
||||
draft_texts: Text
|
||||
draft_versions:
|
||||
edit:
|
||||
back: Back
|
||||
submit_button: Save changes
|
||||
errors:
|
||||
form:
|
||||
error: Error
|
||||
index:
|
||||
title: Draft versions
|
||||
create: Create version
|
||||
new:
|
||||
back: Back
|
||||
title: Create new version
|
||||
submit_button: Create version
|
||||
statuses:
|
||||
draft: Draft
|
||||
published: Published
|
||||
table:
|
||||
title: Títle
|
||||
created_at: Created at
|
||||
comments: Comments
|
||||
final_version: Final version
|
||||
status: Status
|
||||
managers:
|
||||
index:
|
||||
title: Managers
|
||||
|
||||
@@ -91,7 +91,6 @@ es:
|
||||
index:
|
||||
create: Nuevo proceso
|
||||
delete: Borrar
|
||||
edit: Editar
|
||||
title: Procesos de legislación colaborativa
|
||||
filters:
|
||||
open: Abiertos
|
||||
@@ -104,6 +103,32 @@ es:
|
||||
submit_button: Crear proceso
|
||||
process:
|
||||
title: Título del proceso de legislación colaborativa
|
||||
subnav:
|
||||
info: Información
|
||||
draft_texts: Texto
|
||||
draft_versions:
|
||||
edit:
|
||||
back: Volver
|
||||
submit_button: Guardar cambios
|
||||
errors:
|
||||
form:
|
||||
error: Error
|
||||
index:
|
||||
title: Versiones del borrador
|
||||
create: Crear versión
|
||||
new:
|
||||
back: Volver
|
||||
title: Crear nueva versión
|
||||
submit_button: Crear versión
|
||||
statuses:
|
||||
draft: Borrador
|
||||
published: Publicado
|
||||
table:
|
||||
title: Título
|
||||
created_at: Creado
|
||||
comments: Comentarios
|
||||
final_version: Versión final
|
||||
status: Estado
|
||||
managers:
|
||||
index:
|
||||
title: Gestores
|
||||
|
||||
@@ -190,7 +190,9 @@ Rails.application.routes.draw do
|
||||
end
|
||||
|
||||
namespace :legislation do
|
||||
resources :processes
|
||||
resources :processes do
|
||||
resources :draft_versions
|
||||
end
|
||||
end
|
||||
|
||||
namespace :api do
|
||||
|
||||
@@ -355,3 +355,33 @@ Proposal.last(3).each do |proposal|
|
||||
created_at: rand((Time.current - 1.week) .. Time.current))
|
||||
puts " #{banner.title}"
|
||||
end
|
||||
|
||||
puts "Creating legislation processes"
|
||||
|
||||
(1..5).each do |i|
|
||||
process = ::Legislation::Process.create!(title: Faker::Lorem.sentence(3).truncate(60),
|
||||
description: Faker::Lorem.paragraphs.join("\n\n"),
|
||||
target: Faker::Lorem.paragraphs.join("\n\n"),
|
||||
how_to_participate: Faker::Lorem.paragraphs.join("\n\n"),
|
||||
additional_info: Faker::Lorem.paragraphs.join("\n\n"),
|
||||
start_date: Date.current - 3.days,
|
||||
end_date: Date.current + 3.days,
|
||||
debate_start_date: Date.current - 3.days,
|
||||
debate_end_date: Date.current - 1.day,
|
||||
draft_publication_date: Date.current + 1.day,
|
||||
allegations_start_date: Date.current + 2.days,
|
||||
allegations_end_date: Date.current + 3.days,
|
||||
final_publication_date: Date.current + 4.days
|
||||
)
|
||||
puts " #{process.title}"
|
||||
end
|
||||
|
||||
::Legislation::Process.all.each do |process|
|
||||
(1..3).each do |i|
|
||||
version = process.draft_versions.create!(title: "Version #{i}",
|
||||
body: Faker::Lorem.paragraphs.join("\n\n")
|
||||
)
|
||||
puts " #{version.title}"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
class CreateLegislationDraftVersions < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :legislation_draft_versions do |t|
|
||||
t.references :legislation_process, index: true, foreign_key: true
|
||||
t.string :title
|
||||
t.text :changelog
|
||||
t.string :status, index: true, default: :draft
|
||||
t.boolean :final_version, default: false
|
||||
t.text :body
|
||||
|
||||
t.datetime :hidden_at, index: true
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
end
|
||||
end
|
||||
19
db/schema.rb
19
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: 20161117135624) do
|
||||
ActiveRecord::Schema.define(version: 20161205110441) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
@@ -228,6 +228,22 @@ ActiveRecord::Schema.define(version: 20161117135624) do
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
create_table "legislation_draft_versions", force: :cascade do |t|
|
||||
t.integer "legislation_process_id"
|
||||
t.string "title"
|
||||
t.text "changelog"
|
||||
t.string "status", default: "draft"
|
||||
t.boolean "final_version", default: false
|
||||
t.text "body"
|
||||
t.datetime "hidden_at"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
add_index "legislation_draft_versions", ["hidden_at"], name: "index_legislation_draft_versions_on_hidden_at", using: :btree
|
||||
add_index "legislation_draft_versions", ["legislation_process_id"], name: "index_legislation_draft_versions_on_legislation_process_id", using: :btree
|
||||
add_index "legislation_draft_versions", ["status"], name: "index_legislation_draft_versions_on_status", using: :btree
|
||||
|
||||
create_table "legislation_processes", force: :cascade do |t|
|
||||
t.string "title"
|
||||
t.text "description"
|
||||
@@ -584,6 +600,7 @@ ActiveRecord::Schema.define(version: 20161117135624) do
|
||||
add_foreign_key "failed_census_calls", "users"
|
||||
add_foreign_key "flags", "users"
|
||||
add_foreign_key "identities", "users"
|
||||
add_foreign_key "legislation_draft_versions", "legislation_processes"
|
||||
add_foreign_key "locks", "users"
|
||||
add_foreign_key "managers", "users"
|
||||
add_foreign_key "moderators", "users"
|
||||
|
||||
@@ -1,19 +1,4 @@
|
||||
FactoryGirl.define do
|
||||
factory :legislation_process, class: 'Legislation::Process' do
|
||||
title "A collaborative legislation process"
|
||||
description "Description of the process"
|
||||
target "Who will affected by this law?"
|
||||
how_to_participate "You can participate by answering some questions"
|
||||
start_date "2016-11-16"
|
||||
end_date "2016-11-16"
|
||||
debate_start_date "2016-11-16"
|
||||
debate_end_date "2016-11-16"
|
||||
draft_publication_date "2016-11-16"
|
||||
allegations_start_date "2016-11-16"
|
||||
allegations_end_date "2016-11-16"
|
||||
final_publication_date "2016-11-16"
|
||||
end
|
||||
|
||||
sequence(:document_number) { |n| "#{n.to_s.rjust(8, '0')}X" }
|
||||
|
||||
factory :user do
|
||||
@@ -357,4 +342,28 @@ FactoryGirl.define do
|
||||
association :sender, factory: :user
|
||||
association :receiver, factory: :user
|
||||
end
|
||||
|
||||
factory :legislation_process, class: 'Legislation::Process' do
|
||||
title "A collaborative legislation process"
|
||||
description "Description of the process"
|
||||
target "Who will affected by this law?"
|
||||
how_to_participate "You can participate by answering some questions"
|
||||
start_date "2016-11-16"
|
||||
end_date "2016-11-16"
|
||||
debate_start_date "2016-11-16"
|
||||
debate_end_date "2016-11-16"
|
||||
draft_publication_date "2016-11-16"
|
||||
allegations_start_date "2016-11-16"
|
||||
allegations_end_date "2016-11-16"
|
||||
final_publication_date "2016-11-16"
|
||||
end
|
||||
|
||||
factory :legislation_draft_version, class: 'Legislation::DraftVersion' do
|
||||
process factory: :legislation_process
|
||||
title "Version 1"
|
||||
changelog "What changed in this version"
|
||||
status "draft"
|
||||
final_version false
|
||||
body "Body of the legislation text"
|
||||
end
|
||||
end
|
||||
|
||||
66
spec/features/admin/legislation/draft_versions_spec.rb
Normal file
66
spec/features/admin/legislation/draft_versions_spec.rb
Normal file
@@ -0,0 +1,66 @@
|
||||
require 'rails_helper'
|
||||
|
||||
feature 'Admin legislation draft versions' do
|
||||
|
||||
background do
|
||||
admin = create(:administrator)
|
||||
login_as(admin.user)
|
||||
end
|
||||
|
||||
context "Feature flag" do
|
||||
|
||||
scenario 'Disabled with a feature flag' do
|
||||
Setting['feature.legislation'] = nil
|
||||
process = create(:legislation_process)
|
||||
expect{ visit admin_legislation_process_draft_versions_path(process) }.to raise_exception(FeatureFlags::FeatureDisabled)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "Index" do
|
||||
|
||||
scenario 'Displaying legislation process draft versions' do
|
||||
process = create(:legislation_process, title: 'An example legislation process')
|
||||
draft_version = create(:legislation_draft_version, process: process, title: 'Version 1')
|
||||
|
||||
visit admin_legislation_processes_path(filter: 'all')
|
||||
|
||||
click_link 'An example legislation process'
|
||||
click_link 'Text'
|
||||
click_link 'Version 1'
|
||||
|
||||
expect(page).to have_content(draft_version.title)
|
||||
expect(page).to have_content(draft_version.changelog)
|
||||
end
|
||||
end
|
||||
|
||||
context 'Create' do
|
||||
scenario 'Valid legislation draft_version' do
|
||||
process = create(:legislation_process, title: 'An example legislation process')
|
||||
|
||||
visit admin_root_path
|
||||
|
||||
within('#side_menu') do
|
||||
click_link "Collaborative Legislation"
|
||||
end
|
||||
|
||||
click_link "All"
|
||||
|
||||
expect(page).to have_content 'An example legislation process'
|
||||
|
||||
click_link 'An example legislation process'
|
||||
click_link 'Text'
|
||||
|
||||
click_link 'Create version'
|
||||
|
||||
fill_in 'legislation_draft_version_title', with: 'Version 3'
|
||||
fill_in 'legislation_draft_version_changelog', with: 'Version 3 changes'
|
||||
fill_in 'legislation_draft_version_body', with: 'Version 3 body'
|
||||
|
||||
click_button 'Create version'
|
||||
|
||||
expect(page).to have_content 'An example legislation process'
|
||||
expect(page).to have_content 'Version 3'
|
||||
end
|
||||
end
|
||||
end
|
||||
9
spec/models/legislation/draft_version_spec.rb
Normal file
9
spec/models/legislation/draft_version_spec.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Legislation::DraftVersion, type: :model do
|
||||
let(:legislation_draft_version) { build(:legislation_draft_version) }
|
||||
|
||||
it "should be valid" do
|
||||
expect(legislation_draft_version).to be_valid
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user