Merge branch 'master' of github.com:domify/registry

This commit is contained in:
Martin Lensment 2015-07-03 18:33:48 +03:00
commit b0da030889
13 changed files with 158 additions and 68 deletions

View file

@ -5,6 +5,7 @@ AllCops:
- 'Guardfile' - 'Guardfile'
# stuff generated by AR and rails # stuff generated by AR and rails
- 'db/schema.rb' - 'db/schema.rb'
- 'db/schema-read-only.rb'
- 'db/whois_schema.rb' - 'db/whois_schema.rb'
- 'db/api_log_schema.rb' - 'db/api_log_schema.rb'
- 'db/migrate/*' - 'db/migrate/*'

View file

@ -17,7 +17,6 @@ before_script:
- cp config/database-travis.yml config/database.yml - cp config/database-travis.yml config/database.yml
- RAILS_ENV=test bundle exec rake db:all:drop - RAILS_ENV=test bundle exec rake db:all:drop
- RAILS_ENV=test bundle exec rake db:all:setup - RAILS_ENV=test bundle exec rake db:all:setup
- RAILS_ENV=test bundle exec rake zonefile:replace_procedure
script: script:
- RAILS_ENV=test bundle exec rake - RAILS_ENV=test bundle exec rake
cache: bundler cache: bundler

View file

@ -103,9 +103,10 @@ group :development do
# dev tools # dev tools
gem 'spring', '~> 1.3.6' gem 'spring', '~> 1.3.6'
gem 'spring-commands-rspec', '~> 1.0.4' gem 'spring-commands-rspec', '~> 1.0.4'
gem 'spring-watcher-listen', # otherwise spring polls the filesystem on every 0.2 seconds # emits errors, needs more investigation
github: 'jonleighton/spring-watcher-listen', # gem 'spring-watcher-listen', # otherwise spring polls the filesystem on every 0.2 seconds
ref: '7f6003e14f8f9ca178a5194f210c07f54cfb67ec' # github: 'jonleighton/spring-watcher-listen',
# ref: '7f6003e14f8f9ca178a5194f210c07f54cfb67ec'
gem 'guard', '~> 2.12.6' # run tests automatically gem 'guard', '~> 2.12.6' # run tests automatically
gem 'guard-rspec', '~> 4.5.2' gem 'guard-rspec', '~> 4.5.2'
gem 'guard-rails', '~> 0.7.1' # run EPP server automatically gem 'guard-rails', '~> 0.7.1' # run EPP server automatically

View file

@ -24,15 +24,6 @@ GIT
hpricot hpricot
libxml-ruby libxml-ruby
GIT
remote: https://github.com/jonleighton/spring-watcher-listen.git
revision: 7f6003e14f8f9ca178a5194f210c07f54cfb67ec
ref: 7f6003e14f8f9ca178a5194f210c07f54cfb67ec
specs:
spring-watcher-listen (1.0.0)
listen (~> 2.7)
spring (~> 1.2)
GIT GIT
remote: https://github.com/rubysec/bundler-audit.git remote: https://github.com/rubysec/bundler-audit.git
revision: f89ef7fae1090bbad825ea76812d56d72b417055 revision: f89ef7fae1090bbad825ea76812d56d72b417055
@ -625,7 +616,6 @@ DEPENDENCIES
simpleidn (~> 0.0.5) simpleidn (~> 0.0.5)
spring (~> 1.3.6) spring (~> 1.3.6)
spring-commands-rspec (~> 1.0.4) spring-commands-rspec (~> 1.0.4)
spring-watcher-listen!
therubyracer (~> 0.12.2) therubyracer (~> 0.12.2)
traceroute (~> 0.5.0) traceroute (~> 0.5.0)
turbolinks (~> 2.5.3) turbolinks (~> 2.5.3)

View file

@ -3,7 +3,7 @@ class BankTransaction < ActiveRecord::Base
belongs_to :bank_statement belongs_to :bank_statement
has_one :account_activity has_one :account_activity
scope :unbinded, -> { scope :unbinded, lambda {
where('id NOT IN (SELECT bank_transaction_id FROM account_activities where bank_transaction_id IS NOT NULL)') where('id NOT IN (SELECT bank_transaction_id FROM account_activities where bank_transaction_id IS NOT NULL)')
} }

View file

@ -31,8 +31,6 @@ bundle install
RAILS_ENV=test bundle exec rake db:all:drop RAILS_ENV=test bundle exec rake db:all:drop
RAILS_ENV=test bundle exec rake db:all:setup RAILS_ENV=test bundle exec rake db:all:setup
RAILS_ENV=test bundle exec rake zonefile:replace_procedure
RAILS_ENV=test bundle exec rake assets:precompile
echo "GIT_LAST_COMMITS" echo "GIT_LAST_COMMITS"
git log --pretty='%s (%cn, %cr)' --abbrev-commit --graph --decorate -n 20 --no-color git log --pretty='%s (%cn, %cr)' --abbrev-commit --graph --decorate -n 20 --no-color
@ -44,7 +42,7 @@ RCODE=$?
echo "END_OF_RUBOCOP_RESULTS" echo "END_OF_RUBOCOP_RESULTS"
echo "TEST_RESULTS" echo "TEST_RESULTS"
# basic test # basic tests without EPP
# ROBOT=true bundle exec rake # ROBOT=true bundle exec rake
# all tests with EPP # all tests with EPP

View file

@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20150701074344) do ActiveRecord::Schema.define(version: 20150703105159) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
@ -919,27 +919,27 @@ ActiveRecord::Schema.define(version: 20150701074344) do
create_table "pricelists", force: :cascade do |t| create_table "pricelists", force: :cascade do |t|
t.string "desc" t.string "desc"
t.string "category" t.string "category"
t.decimal "price_cents", precision: 8, scale: 2, default: 0.0, null: false t.decimal "price_cents", precision: 10, scale: 2, default: 0.0, null: false
t.string "price_currency", default: "EUR", null: false t.string "price_currency", default: "EUR", null: false
t.datetime "valid_from" t.datetime "valid_from"
t.datetime "valid_to" t.datetime "valid_to"
t.string "creator_str" t.string "creator_str"
t.string "updator_str" t.string "updator_str"
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.string "duration" t.string "duration"
t.string "operation_category" t.string "operation_category"
end end
create_table "que_jobs", id: false, force: :cascade do |t| create_table "que_jobs", id: false, force: :cascade do |t|
t.integer "priority", limit: 2, default: 100, null: false t.integer "priority", limit: 2, default: 100, null: false
t.datetime "run_at", default: '2015-06-29 12:38:58', null: false t.datetime "run_at", default: "now()", null: false
t.integer "job_id", limit: 8, default: 0, null: false t.integer "job_id", limit: 8, default: "nextval('que_jobs_job_id_seq'::regclass)", null: false
t.text "job_class", null: false t.text "job_class", null: false
t.json "args", default: [], null: false t.json "args", default: [], null: false
t.integer "error_count", default: 0, null: false t.integer "error_count", default: 0, null: false
t.text "last_error" t.text "last_error"
t.text "queue", default: "", null: false t.text "queue", default: "", null: false
end end
create_table "registrant_verifications", force: :cascade do |t| create_table "registrant_verifications", force: :cascade do |t|

View file

@ -74,7 +74,7 @@ CREATE FUNCTION generate_zonefile(i_origin character varying) RETURNS text
SELECT concat(d.name_puny, '. IN NS ', ns.hostname, '.') SELECT concat(d.name_puny, '. IN NS ', ns.hostname, '.')
FROM domains d FROM domains d
JOIN nameservers ns ON ns.domain_id = d.id JOIN nameservers ns ON ns.domain_id = d.id
WHERE d.name LIKE include_filter AND d.name NOT LIKE exclude_filter WHERE d.name LIKE include_filter AND d.name NOT LIKE exclude_filter OR d.name = i_origin
ORDER BY d.name ORDER BY d.name
), ),
chr(10) chr(10)
@ -2404,8 +2404,8 @@ ALTER SEQUENCE pricelists_id_seq OWNED BY pricelists.id;
CREATE TABLE que_jobs ( CREATE TABLE que_jobs (
priority smallint DEFAULT 100 NOT NULL, priority smallint DEFAULT 100 NOT NULL,
run_at timestamp without time zone DEFAULT '2015-06-30 14:16:50.905537'::timestamp without time zone NOT NULL, run_at timestamp with time zone DEFAULT now() NOT NULL,
job_id bigint DEFAULT 0 NOT NULL, job_id bigint NOT NULL,
job_class text NOT NULL, job_class text NOT NULL,
args json DEFAULT '[]'::json NOT NULL, args json DEFAULT '[]'::json NOT NULL,
error_count integer DEFAULT 0 NOT NULL, error_count integer DEFAULT 0 NOT NULL,
@ -2414,6 +2414,32 @@ CREATE TABLE que_jobs (
); );
--
-- Name: TABLE que_jobs; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON TABLE que_jobs IS '3';
--
-- Name: que_jobs_job_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE que_jobs_job_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: que_jobs_job_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE que_jobs_job_id_seq OWNED BY que_jobs.job_id;
-- --
-- Name: registrant_verifications; Type: TABLE; Schema: public; Owner: -; Tablespace: -- Name: registrant_verifications; Type: TABLE; Schema: public; Owner: -; Tablespace:
-- --
@ -3169,6 +3195,13 @@ ALTER TABLE ONLY people ALTER COLUMN id SET DEFAULT nextval('people_id_seq'::reg
ALTER TABLE ONLY pricelists ALTER COLUMN id SET DEFAULT nextval('pricelists_id_seq'::regclass); ALTER TABLE ONLY pricelists ALTER COLUMN id SET DEFAULT nextval('pricelists_id_seq'::regclass);
--
-- Name: job_id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY que_jobs ALTER COLUMN job_id SET DEFAULT nextval('que_jobs_job_id_seq'::regclass);
-- --
-- Name: id; Type: DEFAULT; Schema: public; Owner: - -- Name: id; Type: DEFAULT; Schema: public; Owner: -
-- --
@ -3688,6 +3721,14 @@ ALTER TABLE ONLY pricelists
ADD CONSTRAINT pricelists_pkey PRIMARY KEY (id); ADD CONSTRAINT pricelists_pkey PRIMARY KEY (id);
--
-- Name: que_jobs_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY que_jobs
ADD CONSTRAINT que_jobs_pkey PRIMARY KEY (queue, priority, run_at, job_id);
-- --
-- Name: registrant_verifications_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- Name: registrant_verifications_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
-- --
@ -4810,5 +4851,13 @@ INSERT INTO schema_migrations (version) VALUES ('20150612123111');
INSERT INTO schema_migrations (version) VALUES ('20150701074344'); INSERT INTO schema_migrations (version) VALUES ('20150701074344');
INSERT INTO schema_migrations (version) VALUES ('20150703074448');
INSERT INTO schema_migrations (version) VALUES ('20150703084632'); INSERT INTO schema_migrations (version) VALUES ('20150703084632');
INSERT INTO schema_migrations (version) VALUES ('20150703090039');
INSERT INTO schema_migrations (version) VALUES ('20150703104149');
INSERT INTO schema_migrations (version) VALUES ('20150703105159');

View file

@ -32,7 +32,7 @@ status)
start) start)
echo "$1 que monitor and server" echo "$1 que monitor and server"
for i in `seq 1 $QUE_INSTANCES`; do for i in `seq 1 $QUE_INSTANCES`; do
cd $APP_ROOT && RAILS_ENV=$RAILS_ENV $RUBY_BUNDLE_PATH exec rake daemon:que:start cd $APP_ROOT && QUE_WORKER_COUNT=1 RAILS_ENV=$RAILS_ENV $RUBY_BUNDLE_PATH exec rake daemon:que:start
echo '.' echo '.'
done done
;; ;;

View file

@ -1,5 +1,5 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
results = [] results = []
Dir[File.dirname(__FILE__) + "/*_ctl"].each {|f| results << `ruby #{f} #{ARGV.first}`} Dir[File.dirname(__FILE__) + "/*_ctl"].each { |f| results << `ruby #{f} #{ARGV.first}` }
results.delete_if { |result| result.nil? || result.empty? } results.delete_if { |result| result.nil? || result.empty? }
puts results.join unless results.empty? puts results.join unless results.empty?

View file

@ -3,15 +3,16 @@
ENV["RAILS_ENV"] ||= "production" ENV["RAILS_ENV"] ||= "production"
root = File.expand_path(File.dirname(__FILE__)) root = File.expand_path(File.dirname(__FILE__))
root = File.dirname(root) until File.exists?(File.join(root, 'config')) root = File.dirname(root) until File.exist?(File.join(root, 'config'))
Dir.chdir(root) Dir.chdir(root)
require File.join(root, "config", "environment") require File.join(root, "config", "environment")
$running = true @running = true
Signal.trap("TERM") do Signal.trap("TERM") do
$running = false @running = false
end end
while($running) do # rubocop: disable Style/WhileUntilDo
while @running do
end end

View file

@ -1,12 +1,45 @@
Rake::Task["db:schema:load"].clear
Rake::Task["db:migrate"].enhance do
if ActiveRecord::Base.schema_format == :sql
Rake::Task["db:schema:dump"].invoke
end
end
Rake::Task["db:rollback"].enhance do
if ActiveRecord::Base.schema_format == :sql
Rake::Task["db:schema:dump"].invoke
end
end
Rake::Task["db:schema:dump"].enhance do
if ActiveRecord::Base.schema_format == :sql
File.rename('db/schema.rb', 'db/schema-read-only.rb')
Rake::Task["db:structure:dump"].invoke # for users who do manually db:schema:dump
end
end
namespace :db do namespace :db do
namespace :schema do
task load: [:environment, :load_config] do
puts 'Only rake db:structure:load is supported and invoked. ' \
'Otherwise zonefile generation does not work nor que.'
Rake::Task["db:structure:load"].invoke
end
end
def databases def databases
@db ||= [Rails.env, "api_log_#{Rails.env}", "whois_#{Rails.env}"] @db ||= [Rails.env, "api_log_#{Rails.env}", "whois_#{Rails.env}"]
end end
def other_databases
@other_dbs ||= ["api_log_#{Rails.env}", "whois_#{Rails.env}"]
end
def schema_file(db) def schema_file(db)
case db case db
when Rails.env when Rails.env
'schema.rb' 'structure.sql' # just in case
when "api_log_#{Rails.env}" when "api_log_#{Rails.env}"
'api_log_schema.rb' 'api_log_schema.rb'
when "whois_#{Rails.env}" when "whois_#{Rails.env}"
@ -25,7 +58,7 @@ namespace :db do
puts "\n---------------------------- Import seed ----------------------------------------\n" puts "\n---------------------------- Import seed ----------------------------------------\n"
Rake::Task['db:seed'].invoke Rake::Task['db:seed'].invoke
Rake::Task['zonefile:replace_procedure'].invoke # Rake::Task['zonefile:replace_procedure'].invoke # not needed any more
puts "\n All done!\n\n" puts "\n All done!\n\n"
end end
@ -73,7 +106,10 @@ namespace :db do
namespace :schema do namespace :schema do
desc 'Schema load for all databases: registry, api_log and whois' desc 'Schema load for all databases: registry, api_log and whois'
task load: [:environment, :load_config] do task load: [:environment, :load_config] do
databases.each do |name| puts "\n------------------------ #{Rails.env} structure loading -----------------------------\n"
Rake::Task['db:structure:load'].invoke
other_databases.each do |name|
begin begin
puts "\n------------------------ #{name} schema loading -----------------------------\n" puts "\n------------------------ #{name} schema loading -----------------------------\n"
ActiveRecord::Base.clear_all_connections! ActiveRecord::Base.clear_all_connections!
@ -89,9 +125,12 @@ namespace :db do
end end
end end
desc 'Schema load for all databases: registry, api_log and whois' desc 'Schema dump for all databases: registry, api_log and whois'
task dump: [:environment, :load_config] do task dump: [:environment, :load_config] do
databases.each do |name| puts "\n---------------------------- #{Rails.env} structure and schema dump--------------\n"
Rake::Task['db:schema:dump'].invoke # dumps both schema and structure
other_databases.each do |name|
begin begin
puts "\n---------------------------- #{name} ----------------------------------------\n" puts "\n---------------------------- #{name} ----------------------------------------\n"
filename = "#{Rails.root}/db/#{schema_file(name)}" filename = "#{Rails.root}/db/#{schema_file(name)}"
@ -104,6 +143,17 @@ namespace :db do
end end
end end
end end
# alias names
namespace :structure do
desc '(alias) Schema dump for all databases: registry, api_log and whois'
task :dump do
Rake::Task['db:all:schema:dump'].invoke
end
desc '(alias) Schema load for all databases: registry, api_log and whois'
task :load do
Rake::Task['db:all:schema:load'].invoke
end
end
end end
end end
end end

View file

@ -121,31 +121,32 @@ describe 'EPP Keyrelay', epp: true do
@registrar2.messages.queued.count.should == msg_count @registrar2.messages.queued.count.should == msg_count
end end
it 'does not allow both relative and absolute' do # keyrelay not enabled at the moment
msg_count = @registrar2.messages.queued.count # it 'does not allow both relative and absolute' do
xml = @epp_xml.keyrelay({ # msg_count = @registrar2.messages.queued.count
name: { value: @domain.name }, # xml = @epp_xml.keyrelay({
keyData: { # name: { value: @domain.name },
flags: { value: '256' }, # keyData: {
protocol: { value: '3' }, # flags: { value: '256' },
alg: { value: '8' }, # protocol: { value: '3' },
pubKey: { value: 'cmlraXN0aGViZXN0' } # alg: { value: '8' },
}, # pubKey: { value: 'cmlraXN0aGViZXN0' }
authInfo: { # },
pw: { value: @domain.auth_info } # authInfo: {
}, # pw: { value: @domain.auth_info }
expiry: { # },
relative: { value: 'P1D' }, # expiry: {
absolute: { value: '2014-12-23' } # relative: { value: 'P1D' },
} # absolute: { value: '2014-12-23' }
}) # }
# })
response = epp_plain_request(xml, :xml) # response = epp_plain_request(xml, :xml)
response[:msg].should == 'Exactly one parameter required: keyrelay > expiry > relative OR '\ # response[:msg].should == 'Exactly one parameter required: keyrelay > expiry > relative OR '\
'keyrelay > expiry > absolute' # 'keyrelay > expiry > absolute'
@registrar2.messages.queued.count.should == msg_count # @registrar2.messages.queued.count.should == msg_count
end # end
it 'saves legal document with keyrelay' do it 'saves legal document with keyrelay' do
xml = @epp_xml.keyrelay({ xml = @epp_xml.keyrelay({