diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..5fc709227 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,27 @@ +language: ruby +rvm: + - 2.2 + - ruby-head +env: + - DB=postgresql +sudo: false +before_install: + - gem install bundler + - "rm ${BUNDLE_GEMFILE}.lock" +before_script: + - psql -c 'create database registry_test;' -U postgres + - psql -c 'create database registry_whois_test;' -U postgres + - psql -c 'create database registry_api_log_test;' -U postgres + - bundle update + - cp config/application-example.yml config/application.yml + - cp config/secrets-example.yml config/secrets.yml + - cp config/database-travis.yml config/database.yml + - RAILS_ENV=test bundle exec rake db:all:schema:load + - RAILS_ENV=test bundle exec rake db:seed +script: + - RAILS_ENV=test bundle exec rake +cache: bundler +services: + - postgresql +addons: + postgresql: "9.3" diff --git a/Gemfile b/Gemfile index c901c0e56..b9360ace8 100644 --- a/Gemfile +++ b/Gemfile @@ -110,4 +110,7 @@ group :development, :test do # dev tools gem 'unicorn' + + # for travis + gem 'rake' end diff --git a/Gemfile.lock b/Gemfile.lock index 9097efcef..eb77b8396 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -478,6 +478,7 @@ DEPENDENCIES railroady (~> 1.3.0) rails (= 4.2.0) rails-settings-cached (~> 0.4.1) + rake ransack (~> 1.5.1) rspec-rails (~> 3.0.2) rubocop (~> 0.26.1) diff --git a/README.md b/README.md index 2733fd2bd..8b1dabe6d 100644 --- a/README.md +++ b/README.md @@ -359,3 +359,8 @@ This needs a static greeting file, so you will have to make /var/www writable. mkdir epp Copy the files from $mod_epp/examples/cgis to /usr/lib/cgi-bin/epp + +## Code Status + +Alpha release status, only model tests: +[![Build Status](https://travis-ci.org/domify/registry.svg?branch=master)](https://travis-ci.org/domify/registry) diff --git a/app/models/epp/contact.rb b/app/models/epp/contact.rb index 276b490d6..0a6c14020 100644 --- a/app/models/epp/contact.rb +++ b/app/models/epp/contact.rb @@ -5,9 +5,6 @@ class Epp::Contact < Contact # disable STI, there is type column present self.inheritance_column = :sti_disabled - # temp fix - has_many :legal_documents, as: :documentable - class << self # rubocop: disable Metrics/PerceivedComplexity # rubocop: disable Metrics/CyclomaticComplexity @@ -54,11 +51,10 @@ class Epp::Contact < Contact end def legal_document_attrs(legal_frame) - attrs = {}.with_indifferent_access - attrs[0] = {}.with_indifferent_access - attrs[0][:body] = legal_frame.text - attrs[0][:document_type] = legal_frame['type'] - attrs + [{ + body: legal_frame.text, + document_type: legal_frame['type'] + }] end end diff --git a/config/database-travis.yml b/config/database-travis.yml new file mode 100644 index 000000000..bf0765265 --- /dev/null +++ b/config/database-travis.yml @@ -0,0 +1,19 @@ +default: &default + host: localhost + adapter: postgresql + encoding: unicode + pool: 5 + username: postgres + password: + +test: + <<: *default + database: registry_test + +whois_test: + <<: *default + database: registry_whois_test + +api_log_test: + <<: *default + database: registry_api_log_test diff --git a/lib/tasks/db.rake b/lib/tasks/db.rake index 3108ad02f..73f217711 100644 --- a/lib/tasks/db.rake +++ b/lib/tasks/db.rake @@ -41,7 +41,7 @@ namespace :db do databases.each do |name| begin puts "\n---------------------------- #{name} ----------------------------------------\n" - ActiveRecord::Base.establish_connection(name) + ActiveRecord::Base.establish_connection(name.to_sym) if ActiveRecord::Base.connection.table_exists?('schema_migrations') puts 'Found tables, skip schema load!' else diff --git a/lib/tasks/test.rake b/lib/tasks/test.rake index 20e3f5f91..ac5b5159d 100644 --- a/lib/tasks/test.rake +++ b/lib/tasks/test.rake @@ -30,7 +30,7 @@ begin end Rake::Task[:default].prerequisites.clear - task default: :test + task default: 'test:other' def test_against_server _stdin, _stdout, _stderr, wait_thr = Open3.popen3('unicorn -E test -p 8989')