Remove scripts
This commit is contained in:
parent
bbdd03db20
commit
90092b3cf8
|
@ -5,7 +5,3 @@
|
||||||
//= require popper
|
//= require popper
|
||||||
//= require bootstrap-sprockets
|
//= require bootstrap-sprockets
|
||||||
//= require_tree .
|
//= require_tree .
|
||||||
|
|
||||||
document.addEventListener('turbolinks:load', function() {
|
|
||||||
Prism.highlightAll()
|
|
||||||
})
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,3 @@
|
||||||
@import 'bootstrap';
|
@import 'bootstrap';
|
||||||
@import 'font-awesome-sprockets';
|
@import 'font-awesome-sprockets';
|
||||||
@import 'font-awesome';
|
@import 'font-awesome';
|
||||||
|
|
||||||
@import 'prism';
|
|
||||||
|
|
|
@ -1,125 +0,0 @@
|
||||||
/* PrismJS 1.17.1
|
|
||||||
https://prismjs.com/download.html#themes=prism-tomorrow&languages=markup+css+clike+javascript+abap+abnf+actionscript+ada+antlr4+apacheconf+apl+applescript+aql+c+arff+asciidoc+asm6502+csharp+autohotkey+autoit+bash+basic+batch+bison+bnf+brainfuck+bro+cpp+aspnet+arduino+cil+coffeescript+cmake+clojure+ruby+csp+css-extras+d+dart+diff+markup-templating+dns-zone-file+docker+ebnf+eiffel+ejs+elixir+elm+lua+erb+erlang+fsharp+firestore-security-rules+flow+fortran+ftl+gcode+gdscript+gedcom+gherkin+git+glsl+gml+go+graphql+groovy+less+handlebars+haskell+haxe+hcl+http+hpkp+hsts+ichigojam+icon+inform7+ini+io+j+java+scala+php+javastacktrace+jolie+jq+javadoclike+n4js+markdown+json+jsonp+json5+julia+keyman+kotlin+latex+crystal+scheme+liquid+lisp+livescript+lolcode+etlua+makefile+js-templates+django+matlab+mel+mizar+monkey+n1ql+typescript+nand2tetris-hdl+nasm+nginx+nim+nix+nsis+objectivec+ocaml+opencl+oz+parigp+parser+pascal+pascaligo+pcaxis+perl+jsdoc+phpdoc+php-extras+sql+powershell+processing+prolog+properties+protobuf+scss+puppet+pure+python+q+qore+r+js-extras+jsx+renpy+reason+vala+rest+rip+roboconf+robot-framework+textile+rust+sas+sass+stylus+javadoc+lilypond+shell-session+smalltalk+smarty+solidity+soy+turtle+splunk-spl+sqf+plsql+twig+swift+yaml+tcl+haml+toml+tt2+sparql+pug+tsx+t4-templating+visual-basic+t4-cs+regex+vbnet+velocity+verilog+vhdl+vim+t4-vb+wasm+wiki+xeora+xojo+xquery+tap+zig */
|
|
||||||
/**
|
|
||||||
* prism.js tomorrow night eighties for JavaScript, CoffeeScript, CSS and HTML
|
|
||||||
* Based on https://github.com/chriskempson/tomorrow-theme
|
|
||||||
* @author Rose Pritchard
|
|
||||||
*/
|
|
||||||
|
|
||||||
code[class*="language-"],
|
|
||||||
pre[class*="language-"] {
|
|
||||||
color: #ccc;
|
|
||||||
background: none;
|
|
||||||
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
|
|
||||||
font-size: 1em;
|
|
||||||
text-align: left;
|
|
||||||
white-space: pre;
|
|
||||||
word-spacing: normal;
|
|
||||||
word-break: normal;
|
|
||||||
word-wrap: normal;
|
|
||||||
line-height: 1.5;
|
|
||||||
|
|
||||||
-moz-tab-size: 4;
|
|
||||||
-o-tab-size: 4;
|
|
||||||
tab-size: 4;
|
|
||||||
|
|
||||||
-webkit-hyphens: none;
|
|
||||||
-moz-hyphens: none;
|
|
||||||
-ms-hyphens: none;
|
|
||||||
hyphens: none;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Code blocks */
|
|
||||||
pre[class*="language-"] {
|
|
||||||
padding: 1em;
|
|
||||||
margin: .5em 0;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
:not(pre) > code[class*="language-"],
|
|
||||||
pre[class*="language-"] {
|
|
||||||
background: #2d2d2d;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Inline code */
|
|
||||||
:not(pre) > code[class*="language-"] {
|
|
||||||
padding: .1em;
|
|
||||||
border-radius: .3em;
|
|
||||||
white-space: normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
.token.comment,
|
|
||||||
.token.block-comment,
|
|
||||||
.token.prolog,
|
|
||||||
.token.doctype,
|
|
||||||
.token.cdata {
|
|
||||||
color: #999;
|
|
||||||
}
|
|
||||||
|
|
||||||
.token.punctuation {
|
|
||||||
color: #ccc;
|
|
||||||
}
|
|
||||||
|
|
||||||
.token.tag,
|
|
||||||
.token.attr-name,
|
|
||||||
.token.namespace,
|
|
||||||
.token.deleted {
|
|
||||||
color: #e2777a;
|
|
||||||
}
|
|
||||||
|
|
||||||
.token.function-name {
|
|
||||||
color: #6196cc;
|
|
||||||
}
|
|
||||||
|
|
||||||
.token.boolean,
|
|
||||||
.token.number,
|
|
||||||
.token.function {
|
|
||||||
color: #f08d49;
|
|
||||||
}
|
|
||||||
|
|
||||||
.token.property,
|
|
||||||
.token.class-name,
|
|
||||||
.token.constant,
|
|
||||||
.token.symbol {
|
|
||||||
color: #f8c555;
|
|
||||||
}
|
|
||||||
|
|
||||||
.token.selector,
|
|
||||||
.token.important,
|
|
||||||
.token.atrule,
|
|
||||||
.token.keyword,
|
|
||||||
.token.builtin {
|
|
||||||
color: #cc99cd;
|
|
||||||
}
|
|
||||||
|
|
||||||
.token.string,
|
|
||||||
.token.char,
|
|
||||||
.token.attr-value,
|
|
||||||
.token.regex,
|
|
||||||
.token.variable {
|
|
||||||
color: #7ec699;
|
|
||||||
}
|
|
||||||
|
|
||||||
.token.operator,
|
|
||||||
.token.entity,
|
|
||||||
.token.url {
|
|
||||||
color: #67cdcc;
|
|
||||||
}
|
|
||||||
|
|
||||||
.token.important,
|
|
||||||
.token.bold {
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
.token.italic {
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
|
|
||||||
.token.entity {
|
|
||||||
cursor: help;
|
|
||||||
}
|
|
||||||
|
|
||||||
.token.inserted {
|
|
||||||
color: green;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class Staffs::ScriptsController < ApplicationController
|
|
||||||
before_action :set_script, only: :show
|
|
||||||
|
|
||||||
# GET /staff/scripts
|
|
||||||
def index
|
|
||||||
authorize [:staff, Script]
|
|
||||||
@scripts = policy_scope(
|
|
||||||
Script.order(codename: :asc),
|
|
||||||
policy_scope_class: Staff::ScriptPolicy::Scope,
|
|
||||||
).page(params[:page])
|
|
||||||
end
|
|
||||||
|
|
||||||
# GET /staff/scripts/:codename
|
|
||||||
def show
|
|
||||||
authorize [:staff, @script]
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def set_script
|
|
||||||
@script = Script.find_by! codename: params[:codename]
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,21 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class Script < ApplicationRecord
|
|
||||||
###############
|
|
||||||
# Validations #
|
|
||||||
###############
|
|
||||||
|
|
||||||
validates :codename, codename: true, uniqueness: { case_sensitive: false }
|
|
||||||
|
|
||||||
validates :name, good_small_text: true, uniqueness: true
|
|
||||||
|
|
||||||
validates :source_code, presence: true
|
|
||||||
|
|
||||||
###########
|
|
||||||
# Methods #
|
|
||||||
###########
|
|
||||||
|
|
||||||
def to_param
|
|
||||||
codename
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,25 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class Staff::ScriptPolicy < ApplicationPolicy
|
|
||||||
def index?
|
|
||||||
return false if restricted?
|
|
||||||
|
|
||||||
account&.superuser?
|
|
||||||
end
|
|
||||||
|
|
||||||
def show?
|
|
||||||
return false if restricted?
|
|
||||||
|
|
||||||
account&.superuser?
|
|
||||||
end
|
|
||||||
|
|
||||||
class Scope < Scope
|
|
||||||
def resolve
|
|
||||||
return scope.none if restricted?
|
|
||||||
|
|
||||||
return scope.all if account&.superuser?
|
|
||||||
|
|
||||||
scope.none
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -48,12 +48,5 @@
|
||||||
staff_org_units_path %>
|
staff_org_units_path %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if policy([:staff, Script]).index? %>
|
|
||||||
<li>
|
|
||||||
<%= link_to Script.model_name.human(count: 0),
|
|
||||||
staff_scripts_path %>
|
|
||||||
</li>
|
|
||||||
<% end %>
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
<table class="table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col">
|
|
||||||
<%= Script.human_attribute_name :codename %>
|
|
||||||
</th>
|
|
||||||
<th scope="col">
|
|
||||||
<%= Script.human_attribute_name :name %>
|
|
||||||
</th>
|
|
||||||
<th scope="col"></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
|
|
||||||
<tbody>
|
|
||||||
<% scripts.each do |script| %>
|
|
||||||
<tr>
|
|
||||||
<td scope="row"><%= script.codename %></td>
|
|
||||||
<td><%= script.name %></td>
|
|
||||||
<td>
|
|
||||||
<% if policy([:staff, script]).show? %>
|
|
||||||
<%= open_action [:staff, script] %>
|
|
||||||
<% end %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<% end %>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
|
@ -1,9 +0,0 @@
|
||||||
<div class="container">
|
|
||||||
<%= nav_breadcrumb(
|
|
||||||
[translate(:staff_services), staff_root_path],
|
|
||||||
Script.model_name.human(count: 0),
|
|
||||||
) %>
|
|
||||||
|
|
||||||
<%= render partial: 'table', locals: { scripts: @scripts } %>
|
|
||||||
<%= pagination @scripts %>
|
|
||||||
</div>
|
|
|
@ -1,19 +0,0 @@
|
||||||
<div class="container">
|
|
||||||
<%= nav_breadcrumb(
|
|
||||||
[translate(:staff_services), staff_root_path],
|
|
||||||
[Script.model_name.human(count: 0), staff_scripts_path],
|
|
||||||
@script.codename,
|
|
||||||
) %>
|
|
||||||
|
|
||||||
<dl>
|
|
||||||
<dt><%= Script.human_attribute_name :codename %></dt>
|
|
||||||
<dd><%= @script.codename %></dd>
|
|
||||||
|
|
||||||
<dt><%= Script.human_attribute_name :name %></dt>
|
|
||||||
<dd><%= @script.name %></dd>
|
|
||||||
</dl>
|
|
||||||
|
|
||||||
<hr/>
|
|
||||||
|
|
||||||
<pre><code class="language-ruby"><%= @script.source_code %></code></pre>
|
|
||||||
</div>
|
|
|
@ -38,10 +38,6 @@ en:
|
||||||
relationship:
|
relationship:
|
||||||
one: Party relation
|
one: Party relation
|
||||||
many: Party relations
|
many: Party relations
|
||||||
script:
|
|
||||||
one: Script
|
|
||||||
few: Scripts
|
|
||||||
many: Scripts
|
|
||||||
session:
|
session:
|
||||||
one: Session
|
one: Session
|
||||||
few: Sessions
|
few: Sessions
|
||||||
|
@ -124,11 +120,6 @@ en:
|
||||||
relationship:
|
relationship:
|
||||||
id: ID
|
id: ID
|
||||||
from_date: From date
|
from_date: From date
|
||||||
script:
|
|
||||||
id: ID
|
|
||||||
codename: Codename
|
|
||||||
name: Name
|
|
||||||
source_code: Source code
|
|
||||||
session:
|
session:
|
||||||
id: ID
|
id: ID
|
||||||
account: Account
|
account: Account
|
||||||
|
|
|
@ -38,10 +38,6 @@ ru:
|
||||||
relationship:
|
relationship:
|
||||||
one: Отношение с партией
|
one: Отношение с партией
|
||||||
one: Отношения с партией
|
one: Отношения с партией
|
||||||
script:
|
|
||||||
one: Скрипт
|
|
||||||
few: Скрипты
|
|
||||||
many: Скрипты
|
|
||||||
session:
|
session:
|
||||||
one: Сессия
|
one: Сессия
|
||||||
few: Сессии
|
few: Сессии
|
||||||
|
@ -124,11 +120,6 @@ ru:
|
||||||
relationship:
|
relationship:
|
||||||
id: ID
|
id: ID
|
||||||
from_date: Дата начала
|
from_date: Дата начала
|
||||||
script:
|
|
||||||
id: ID
|
|
||||||
codename: Кодовое имя
|
|
||||||
name: Название
|
|
||||||
source_code: Исходный код
|
|
||||||
session:
|
session:
|
||||||
id: ID
|
id: ID
|
||||||
account: Аккаунт
|
account: Аккаунт
|
||||||
|
|
|
@ -67,8 +67,6 @@ Rails.application.routes.draw do
|
||||||
|
|
||||||
resources :org_units, only: %i[index show]
|
resources :org_units, only: %i[index show]
|
||||||
|
|
||||||
resources :scripts, param: :codename, only: %i[index show]
|
|
||||||
|
|
||||||
resources :people, only: %i[index show new create] do
|
resources :people, only: %i[index show new create] do
|
||||||
resources :person_comments,
|
resources :person_comments,
|
||||||
path: 'comments',
|
path: 'comments',
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
accept_as_supporter | Принять в сторонники |
|
|
||||||
accept_as_member | Принять в члены |
|
|
||||||
exit_from_supporters | Выйти из сторонников |
|
|
||||||
exclude_from_supporters | Исключить из сторонников |
|
|
||||||
pause_membership | Приостановить членство |
|
|
||||||
exit_from_members | Выйти из членов |
|
|
||||||
exclude_from_members | Исключить из членов |
|
|
||||||
resume_membership | Возобновить членство |
|
|
||||||
accept_former_supp_as_supporter | Принять в сторонники бывшего сторонника |
|
|
||||||
accept_former_member_as_supporter | Принять в сторонники бывшего члена |
|
|
||||||
accept_excluded_supp_as_supporter | Принять в сторонники исключённого сторонника |
|
|
||||||
accept_excluded_member_as_supporter | Принять в сторонники исключённого члена |
|
|
|
|
@ -1,24 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class CreateScripts < ActiveRecord::Migration[6.0]
|
|
||||||
include Partynest::Migration
|
|
||||||
|
|
||||||
def change
|
|
||||||
create_table :scripts do |t|
|
|
||||||
t.timestamps null: false
|
|
||||||
|
|
||||||
t.string :codename, null: false, index: { unique: true }
|
|
||||||
t.string :name, null: false, index: { unique: true }
|
|
||||||
|
|
||||||
t.text :source_code, null: false
|
|
||||||
end
|
|
||||||
|
|
||||||
add_constraint :scripts, :codename, <<~SQL
|
|
||||||
is_codename(codename)
|
|
||||||
SQL
|
|
||||||
|
|
||||||
add_constraint :scripts, :name, <<~SQL
|
|
||||||
is_good_small_text(name)
|
|
||||||
SQL
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
|
@ -1,142 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class AcceptAsSupporterProgram
|
|
||||||
attr_reader :current_account, :person, :federal_subject
|
|
||||||
|
|
||||||
def initialize(current_account, person, federal_subject)
|
|
||||||
self.current_account = current_account
|
|
||||||
self.person = person
|
|
||||||
self.federal_subject = federal_subject
|
|
||||||
end
|
|
||||||
|
|
||||||
def active?
|
|
||||||
latest_lpr_relationship.nil?
|
|
||||||
end
|
|
||||||
|
|
||||||
def call
|
|
||||||
[lpr_rel, reg_dept_rel] if active?
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def current_account=(value)
|
|
||||||
unless value.instance_of? Account
|
|
||||||
raise TypeError, "Expected #{Account}, got #{value.class}"
|
|
||||||
end
|
|
||||||
raise 'Expected record to be persisted' unless value.persisted?
|
|
||||||
|
|
||||||
@current_account = value
|
|
||||||
end
|
|
||||||
|
|
||||||
def person=(value)
|
|
||||||
unless value.instance_of? Person
|
|
||||||
raise TypeError, "Expected #{Person}, got #{value.class}"
|
|
||||||
end
|
|
||||||
raise 'Expected record to be persisted' unless value.persisted?
|
|
||||||
|
|
||||||
@person = value
|
|
||||||
end
|
|
||||||
|
|
||||||
def federal_subject=(value)
|
|
||||||
unless value.instance_of? FederalSubject
|
|
||||||
raise TypeError, "Expected #{FederalSubject}, got #{value.class}"
|
|
||||||
end
|
|
||||||
raise 'Expected record to be persisted' unless value.persisted?
|
|
||||||
|
|
||||||
@federal_subject = value
|
|
||||||
end
|
|
||||||
|
|
||||||
#####################
|
|
||||||
# Relation statuses #
|
|
||||||
#####################
|
|
||||||
|
|
||||||
def included_rel_status
|
|
||||||
@included_rel_status ||= RelationStatus.find_by! codename: :included
|
|
||||||
end
|
|
||||||
|
|
||||||
def supporter_rel_status
|
|
||||||
@supporter_rel_status ||= RelationStatus.find_by! codename: :supporter
|
|
||||||
end
|
|
||||||
|
|
||||||
#############################
|
|
||||||
# Organizational unit types #
|
|
||||||
#############################
|
|
||||||
|
|
||||||
def lpr_org_unit_kind
|
|
||||||
@lpr_org_unit_kind ||= OrgUnitKind.find_by! codename: :lpr
|
|
||||||
end
|
|
||||||
|
|
||||||
def reg_dept_org_unit_kind
|
|
||||||
@reg_dept_org_unit_kind ||= OrgUnitKind.find_by! codename: :reg_dept
|
|
||||||
end
|
|
||||||
|
|
||||||
########################
|
|
||||||
# Organizational units #
|
|
||||||
########################
|
|
||||||
|
|
||||||
def lpr_org_unit
|
|
||||||
@lpr_org_unit ||=
|
|
||||||
lpr_org_unit_kind
|
|
||||||
.instances
|
|
||||||
.order(created_at: :asc)
|
|
||||||
.first
|
|
||||||
end
|
|
||||||
|
|
||||||
def reg_dept_org_unit
|
|
||||||
@reg_dept_org_unit ||=
|
|
||||||
reg_dept_org_unit_kind
|
|
||||||
.instances
|
|
||||||
.where(resource: federal_subject)
|
|
||||||
.order(created_at: :asc)
|
|
||||||
.first
|
|
||||||
end
|
|
||||||
|
|
||||||
######################
|
|
||||||
# Manipulated person #
|
|
||||||
######################
|
|
||||||
|
|
||||||
def current_person
|
|
||||||
@current_person ||= current_account.person
|
|
||||||
end
|
|
||||||
|
|
||||||
def latest_lpr_relationship
|
|
||||||
if instance_variable_defined? :@latest_lpr_relationship
|
|
||||||
return @latest_lpr_relationship
|
|
||||||
end
|
|
||||||
|
|
||||||
@latest_lpr_relationship =
|
|
||||||
person
|
|
||||||
.all_relationships
|
|
||||||
.where(org_unit: lpr_org_unit)
|
|
||||||
.order(from_date: :asc)
|
|
||||||
.last
|
|
||||||
end
|
|
||||||
|
|
||||||
####################
|
|
||||||
# Generated values #
|
|
||||||
####################
|
|
||||||
|
|
||||||
def from_date
|
|
||||||
@from_date ||= Time.zone.now.to_date
|
|
||||||
end
|
|
||||||
|
|
||||||
def lpr_rel
|
|
||||||
@lpr_rel ||= Relationship.create!(
|
|
||||||
org_unit: lpr_org_unit,
|
|
||||||
parent_rel: nil,
|
|
||||||
status: included_rel_status,
|
|
||||||
person: person,
|
|
||||||
from_date: from_date,
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
def reg_dept_rel
|
|
||||||
@reg_dept_rel ||= Relationship.create!(
|
|
||||||
org_unit: reg_dept_org_unit,
|
|
||||||
parent_rel: lpr_rel,
|
|
||||||
status: supporter_rel_status,
|
|
||||||
person: person,
|
|
||||||
from_date: from_date,
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
|
@ -1 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
|
@ -1 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
|
@ -1 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
|
@ -1 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
|
@ -1 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
|
@ -1 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
|
@ -1 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
|
@ -1 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
|
@ -1 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
15
db/seeds.rb
15
db/seeds.rb
|
@ -79,21 +79,6 @@ do |(org_unit_kind, codename, name)|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
csv_foreach :scripts \
|
|
||||||
do |(codename, name)|
|
|
||||||
codename.strip!
|
|
||||||
name.strip!
|
|
||||||
|
|
||||||
source_code = File.read(
|
|
||||||
File.expand_path(File.join('scripts', "#{codename}.rb"), __dir__),
|
|
||||||
)
|
|
||||||
|
|
||||||
Script.where(codename: codename).first_or_create!(
|
|
||||||
name: name,
|
|
||||||
source_code: source_code,
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
Rails.application.settings(:superuser).tap do |config|
|
Rails.application.settings(:superuser).tap do |config|
|
||||||
user = User.where(email: config[:email]).first_or_create! do |new_user|
|
user = User.where(email: config[:email]).first_or_create! do |new_user|
|
||||||
new_user.password = config[:password]
|
new_user.password = config[:password]
|
||||||
|
|
|
@ -1042,41 +1042,6 @@ CREATE TABLE public.schema_migrations (
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Name: scripts; Type: TABLE; Schema: public; Owner: -
|
|
||||||
--
|
|
||||||
|
|
||||||
CREATE TABLE public.scripts (
|
|
||||||
id bigint NOT NULL,
|
|
||||||
created_at timestamp(6) without time zone NOT NULL,
|
|
||||||
updated_at timestamp(6) without time zone NOT NULL,
|
|
||||||
codename character varying NOT NULL,
|
|
||||||
name character varying NOT NULL,
|
|
||||||
source_code text NOT NULL,
|
|
||||||
CONSTRAINT codename CHECK (public.is_codename((codename)::text)),
|
|
||||||
CONSTRAINT name CHECK (public.is_good_small_text((name)::text))
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Name: scripts_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
|
||||||
--
|
|
||||||
|
|
||||||
CREATE SEQUENCE public.scripts_id_seq
|
|
||||||
START WITH 1
|
|
||||||
INCREMENT BY 1
|
|
||||||
NO MINVALUE
|
|
||||||
NO MAXVALUE
|
|
||||||
CACHE 1;
|
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Name: scripts_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
|
|
||||||
--
|
|
||||||
|
|
||||||
ALTER SEQUENCE public.scripts_id_seq OWNED BY public.scripts.id;
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: sessions; Type: TABLE; Schema: public; Owner: -
|
-- Name: sessions; Type: TABLE; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -1293,13 +1258,6 @@ ALTER TABLE ONLY public.relation_statuses ALTER COLUMN id SET DEFAULT nextval('p
|
||||||
ALTER TABLE ONLY public.relationships ALTER COLUMN id SET DEFAULT nextval('public.relationships_id_seq'::regclass);
|
ALTER TABLE ONLY public.relationships ALTER COLUMN id SET DEFAULT nextval('public.relationships_id_seq'::regclass);
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Name: scripts id; Type: DEFAULT; Schema: public; Owner: -
|
|
||||||
--
|
|
||||||
|
|
||||||
ALTER TABLE ONLY public.scripts ALTER COLUMN id SET DEFAULT nextval('public.scripts_id_seq'::regclass);
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: sessions id; Type: DEFAULT; Schema: public; Owner: -
|
-- Name: sessions id; Type: DEFAULT; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -1449,14 +1407,6 @@ ALTER TABLE ONLY public.schema_migrations
|
||||||
ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version);
|
ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version);
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Name: scripts scripts_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
|
||||||
--
|
|
||||||
|
|
||||||
ALTER TABLE ONLY public.scripts
|
|
||||||
ADD CONSTRAINT scripts_pkey PRIMARY KEY (id);
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: sessions sessions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
-- Name: sessions sessions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -1740,20 +1690,6 @@ CREATE UNIQUE INDEX index_relationships_on_person_id_and_org_unit_id_and_from_da
|
||||||
CREATE INDEX index_relationships_on_status_id ON public.relationships USING btree (status_id);
|
CREATE INDEX index_relationships_on_status_id ON public.relationships USING btree (status_id);
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Name: index_scripts_on_codename; Type: INDEX; Schema: public; Owner: -
|
|
||||||
--
|
|
||||||
|
|
||||||
CREATE UNIQUE INDEX index_scripts_on_codename ON public.scripts USING btree (codename);
|
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Name: index_scripts_on_name; Type: INDEX; Schema: public; Owner: -
|
|
||||||
--
|
|
||||||
|
|
||||||
CREATE UNIQUE INDEX index_scripts_on_name ON public.scripts USING btree (name);
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: index_sessions_on_account_id; Type: INDEX; Schema: public; Owner: -
|
-- Name: index_sessions_on_account_id; Type: INDEX; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -2041,7 +1977,6 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||||
('20191002002101'),
|
('20191002002101'),
|
||||||
('20191002170727'),
|
('20191002170727'),
|
||||||
('20191021060000'),
|
('20191021060000'),
|
||||||
('20191021061920'),
|
('20191021061920');
|
||||||
('20191021093331');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
FactoryBot.define do
|
|
||||||
factory :some_script, class: Script do
|
|
||||||
codename { Faker::Internet.unique.username 3..36, %w[_] }
|
|
||||||
name { Faker::Company.unique.name }
|
|
||||||
|
|
||||||
source_code { "puts 'Hello, World!'\n" }
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,85 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe Script do
|
|
||||||
subject { create :some_script }
|
|
||||||
|
|
||||||
describe '#to_param' do
|
|
||||||
specify do
|
|
||||||
expect(subject.to_param).to eq subject.codename
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#codename' do
|
|
||||||
def allow_value(*)
|
|
||||||
super.for :codename
|
|
||||||
end
|
|
||||||
|
|
||||||
it { is_expected.to validate_presence_of :codename }
|
|
||||||
it { is_expected.to validate_uniqueness_of(:codename).case_insensitive }
|
|
||||||
|
|
||||||
it do
|
|
||||||
is_expected.to validate_length_of(:codename).is_at_least(3).is_at_most(36)
|
|
||||||
end
|
|
||||||
|
|
||||||
it { is_expected.not_to allow_value nil }
|
|
||||||
it { is_expected.not_to allow_value '' }
|
|
||||||
it { is_expected.not_to allow_value ' ' * 3 }
|
|
||||||
|
|
||||||
it { is_expected.to allow_value Faker::Internet.username(3..36, %w[_]) }
|
|
||||||
it { is_expected.to allow_value 'foo_bar' }
|
|
||||||
it { is_expected.to allow_value 'foo123' }
|
|
||||||
|
|
||||||
it do
|
|
||||||
is_expected.not_to \
|
|
||||||
allow_value Faker::Internet.username(3..36, %w[_]).upcase
|
|
||||||
end
|
|
||||||
|
|
||||||
it { is_expected.not_to allow_value Faker::Internet.email }
|
|
||||||
it { is_expected.not_to allow_value '_foo' }
|
|
||||||
it { is_expected.not_to allow_value 'bar_' }
|
|
||||||
it { is_expected.not_to allow_value '1foo' }
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#name' do
|
|
||||||
def allow_value(*)
|
|
||||||
super.for :name
|
|
||||||
end
|
|
||||||
|
|
||||||
it { is_expected.to validate_presence_of :name }
|
|
||||||
it { is_expected.to validate_uniqueness_of :name }
|
|
||||||
|
|
||||||
it do
|
|
||||||
is_expected.to \
|
|
||||||
validate_length_of(:name)
|
|
||||||
.is_at_least(1)
|
|
||||||
.is_at_most(255)
|
|
||||||
end
|
|
||||||
|
|
||||||
it { is_expected.not_to allow_value nil }
|
|
||||||
it { is_expected.not_to allow_value '' }
|
|
||||||
it { is_expected.not_to allow_value ' ' }
|
|
||||||
|
|
||||||
it { is_expected.to allow_value Faker::Name.name }
|
|
||||||
it { is_expected.to allow_value Faker::Name.first_name }
|
|
||||||
it { is_expected.to allow_value 'Foo Bar' }
|
|
||||||
|
|
||||||
it { is_expected.not_to allow_value ' Foo' }
|
|
||||||
it { is_expected.not_to allow_value 'Foo ' }
|
|
||||||
it { is_expected.not_to allow_value "\tFoo" }
|
|
||||||
it { is_expected.not_to allow_value "Foo\t" }
|
|
||||||
it { is_expected.not_to allow_value "\nFoo" }
|
|
||||||
it { is_expected.not_to allow_value "Foo\n" }
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#source_code' do
|
|
||||||
def allow_value(*)
|
|
||||||
super.for :source_code
|
|
||||||
end
|
|
||||||
|
|
||||||
it { is_expected.to validate_presence_of :source_code }
|
|
||||||
|
|
||||||
it { is_expected.to allow_value "puts 'Hello, World!'\n" }
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,7 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe Staff::ScriptPolicy do
|
|
||||||
pending "add some examples to (or delete) #{__FILE__}"
|
|
||||||
end
|
|
Reference in New Issue