diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..e69de29bb diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..0d98e21a2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,44 @@ +FROM gitlab/registry +MAINTAINER Gitlab + +# Initial build +# SSH authorized keys setup +# ADD ./doc/docker/ssh/authorized_keys /root/.ssh/authorized_keys +# +# Apache2 setup +ADD ./doc/docker/apache2/ /etc/apache2/sites-enabled + +# Use baseimage-docker's init process. +CMD ["/sbin/my_init"] + +# Set correct environment variables. +ENV RAILS_ENV production +ENV HOME /home/app + +# Registry +# WORKDIR /home/app/registry +# ADD . /home/app/registry +# RUN chown -R app:www-data .; chmod -R 750 .; chmod g+s .; umask 027 +# RUN setuser app ls -la /home/app/registry/vendor/ +# # RUN setuser app ls -la /home/app/registry/vendor/bundle +# RUN rm /home/app/registry/vendor/bundle -rf +# RUN setuser app bundle install --deployment +# RUN setuser app rake assets:precompile + +# Registry test +# WORKDIR /home/app/registry-test +# ADD . /home/app/registry-test +# RUN chown -R app:www-data .; chmod -R 750 .; chmod g+s .; umask 027 +# RUN setuser app bundle install + +# Ports +# Registry admin: +EXPOSE 80 +# EPP: +EXPOSE 700 +# Test env what jenkins uses +# for debugging only: +# EXPOSE 81 + +# Clean up when done. +RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* diff --git a/Gemfile b/Gemfile index 8b8db709c..576916b45 100644 --- a/Gemfile +++ b/Gemfile @@ -80,6 +80,7 @@ group :development, :test do gem 'capybara', '~> 2.4.1' # For feature testing # gem 'capybara-webkit', '1.2.0' # Webkit driver didn't work with turbolinks + gem 'phantomjs-binaries', '~> 1.9.2.4' gem 'phantomjs', '~> 1.9.7.1', require: 'phantomjs/poltergeist' gem 'poltergeist', '~> 1.5.1' # We are using PhantomJS instead @@ -108,3 +109,4 @@ group :development, :test do # For unique IDs (used by the epp gem) gem 'uuidtools', '~> 2.1.4' end + diff --git a/Gemfile.lock b/Gemfile.lock index 97a3aba09..663979f79 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -29,7 +29,9 @@ GEM tzinfo (~> 1.1) arel (5.0.1.20140414130214) ast (2.0.0) - bootstrap-sass (3.2.0.1) + astrolabe (1.3.0) + parser (>= 2.2.0.pre.3, < 3.0) + bootstrap-sass (3.2.0.2) sass (~> 3.2) builder (3.2.2) capybara (2.4.1) @@ -38,14 +40,14 @@ GEM rack (>= 1.0.0) rack-test (>= 0.5.4) xpath (~> 2.0) - celluloid (0.15.2) - timers (~> 1.1.0) + celluloid (0.16.0) + timers (~> 4.0.0) cliver (0.3.2) coderay (1.1.0) coffee-rails (4.0.1) coffee-script (>= 2.2.0) railties (>= 4.0.0, < 5.0) - coffee-script (2.2.0) + coffee-script (2.3.0) coffee-script-source execjs coffee-script-source (1.7.0) @@ -55,7 +57,7 @@ GEM hpricot libxml-ruby erubis (2.7.0) - execjs (2.2.0) + execjs (2.2.1) fabrication (2.11.3) faker (1.3.0) i18n (~> 0.5) @@ -81,13 +83,14 @@ GEM haml (>= 3.1, < 5.0) railties (>= 4.0.1) hike (1.2.3) + hitimes (1.2.2) hpricot (0.8.6) i18n (0.6.11) isikukood (0.1.2) - jbuilder (2.1.1) + jbuilder (2.1.3) activesupport (>= 3.0.0, < 5) multi_json (~> 1.2) - jquery-rails (3.1.0) + jquery-rails (3.1.2) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) json (1.8.1) @@ -95,7 +98,7 @@ GEM actionpack (>= 3.0.0) activesupport (>= 3.0.0) kgio (2.9.2) - libv8 (3.16.14.3) + libv8 (3.16.14.5) libxml-ruby (2.7.0) listen (2.7.9) celluloid (>= 0.15.2) @@ -108,7 +111,7 @@ GEM method_source (0.8.2) mime-types (1.25.1) mini_portile (0.6.0) - minitest (5.4.0) + minitest (5.4.1) multi_json (1.10.1) nokogiri (1.6.2.1) mini_portile (= 0.6.0) @@ -118,6 +121,8 @@ GEM slop (~> 3.4, >= 3.4.5) pg (0.17.1) phantomjs (1.9.7.1) + phantomjs-binaries (1.9.2.4) + sys-uname (= 0.9.0) poltergeist (1.5.1) capybara (~> 2.1) cliver (~> 0.3.1) @@ -161,7 +166,7 @@ GEM rb-fsevent (0.9.4) rb-inotify (0.9.5) ffi (>= 0.5.0) - rdoc (4.1.1) + rdoc (4.1.2) json (~> 1.4) ref (1.0.5) rspec (3.0.0) @@ -184,7 +189,8 @@ GEM rspec-mocks (~> 3.0.0) rspec-support (~> 3.0.0) rspec-support (3.0.4) - rubocop (0.25.0) + rubocop (0.26.0) + astrolabe (~> 1.3) parser (>= 2.2.0.pre.4, < 3.0) powerpack (~> 0.0.6) rainbow (>= 1.99.1, < 3.0) @@ -196,10 +202,10 @@ GEM sass (~> 3.2.0) sprockets (~> 2.8, <= 2.11.0) sprockets-rails (~> 2.0) - sdoc (0.4.0) - json (~> 1.8) - rdoc (~> 4.0, < 5.0) - shoulda-matchers (2.6.1) + sdoc (0.4.1) + json (~> 1.7, >= 1.7.7) + rdoc (~> 4.0) + shoulda-matchers (2.6.2) activesupport (>= 3.0.0) simpleidn (0.0.5) slop (3.6.0) @@ -209,32 +215,35 @@ GEM multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sprockets-rails (2.1.3) + sprockets-rails (2.1.4) actionpack (>= 3.0) activesupport (>= 3.0) sprockets (~> 2.8) + sys-uname (0.9.0) + ffi (>= 1.0.0) therubyracer (0.12.1) libv8 (~> 3.16.14.0) ref thor (0.19.1) thread_safe (0.3.4) tilt (1.4.1) - timers (1.1.0) + timers (4.0.1) + hitimes treetop (1.4.15) polyglot polyglot (>= 0.3.1) - turbolinks (2.2.2) + turbolinks (2.3.0) coffee-rails tzinfo (1.2.2) thread_safe (~> 0.1) - uglifier (2.5.1) + uglifier (2.5.3) execjs (>= 0.3.0) json (>= 1.8.0) unicorn (4.8.3) kgio (~> 2.6) rack raindrops (~> 0.7) - uuidtools (2.1.4) + uuidtools (2.1.5) websocket-driver (0.3.4) xpath (2.0.0) nokogiri (~> 1.3) @@ -262,6 +271,7 @@ DEPENDENCIES nprogress-rails (~> 0.1.3.1) pg phantomjs (~> 1.9.7.1) + phantomjs-binaries (~> 1.9.2.4) poltergeist (~> 1.5.1) pry (~> 0.10.1) rails (= 4.1.4) diff --git a/app/controllers/admin/contacts_controller.rb b/app/controllers/admin/contacts_controller.rb index 5502dfe93..c07222814 100644 --- a/app/controllers/admin/contacts_controller.rb +++ b/app/controllers/admin/contacts_controller.rb @@ -1,15 +1,50 @@ class Admin::ContactsController < ApplicationController - before_action :set_contact, only: [:show] - - def new - @contact = Contact.new - end + # TODO created_by and updated_by ids + before_action :set_contact, only: [:show, :destroy, :edit, :update] def index @q = Contact.search(params[:q]) @contacts = @q.result.page(params[:page]) end + def new + @contact = Contact.new + @contact.build_local_address + @contact.build_international_address + end + + def create + @contact = Contact.new(contact_params) + @contact.generate_code + if @contact.save + flash[:notice] = I18n.t('shared.contact_added') + redirect_to [:admin, @contact] + else + flash[:alert] = I18n.t('shared.failed_to_create_contact') + render "new" + end + end + + def destroy + if @contact.destroy_and_clean + flash[:notice] = I18n.t('shared.contact_deleted') + redirect_to admin_contacts_path + else + flash[:alert] = I18n.t('shared.failed_to_delete_contact') + redirect_to [:admin, @contact] + end + end + + def update + if @contact.update_attributes(contact_params) + flash[:notice] = I18n.t('shared.contact_updated') + redirect_to [:admin, @contact] + else + flash[:alert] = I18n.t('shared.failed_to_update_contact') + redirect_to [:admin, @contact] + end + end + def search render json: Contact.search_by_query(params[:q]) end @@ -19,4 +54,10 @@ class Admin::ContactsController < ApplicationController def set_contact @contact = Contact.find(params[:id]) end + + def contact_params + params.require(:contact).permit( :email, :phone, :fax, :ident_type, :ident, :auth_info, + local_address_attributes: [:city, :street, :zip, :street2, :street3, :name, :org_name, :country_id], + international_address_attributes: [:city, :street, :zip, :street2, :street3, :name, :org_name, :country_id]) + end end diff --git a/app/models/contact.rb b/app/models/contact.rb index d18959208..6ecac57e4 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -19,6 +19,7 @@ class Contact < ActiveRecord::Base validates :code, :phone, :email, :ident, presence: true validate :ident_must_be_valid + validate :presence_of_one_address validates :phone, format: /\+[0-9]{1,3}\.[0-9]{1,14}?/ # /\+\d{3}\.\d+/ validates :email, format: /@/ @@ -44,12 +45,21 @@ class Contact < ActiveRecord::Base CONTACT_TYPE_ADMIN = 'admin' CONTACT_TYPES = [CONTACT_TYPE_TECH, CONTACT_TYPE_ADMIN] + # TEMP Scope until confusion with contact name is sorted out + # scope :named, -> { joins(:international_address).uniq.all } + # TEMP METHOD for transaction to STI def address international_address end ## + def presence_of_one_address + return true if local_address || international_address + errors.add(:local_address, 'Local or international address must be present') + errors.add(:international_address, 'Local or international address must be present') + end + def ident_must_be_valid # TODO: Ident can also be passport number or company registry code. # so have to make changes to validations (and doc/schema) accordingly @@ -79,7 +89,6 @@ class Contact < ActiveRecord::Base end # generate random id for contact - # def generate_code self.code = SecureRandom.hex(4) end @@ -124,6 +133,9 @@ class Contact < ActiveRecord::Base end class << self + # non-EPP + + # EPP def extract_attributes(ph, type = :create) contact_hash = { phone: ph[:voice], diff --git a/app/views/admin/contacts/_form.haml b/app/views/admin/contacts/_form.haml index 9386476fb..a3285a42c 100644 --- a/app/views/admin/contacts/_form.haml +++ b/app/views/admin/contacts/_form.haml @@ -1 +1,77 @@ -to be done += form_for([:admin, @contact]) do |f| + - if @contact.errors.any? + - @contact.errors.each do |attr, err| + = err + %br + - if @contact.errors.any? + %hr + + .row + .col-md-6.text-left + .form-group + = f.label :email + = f.text_field(:email, class: 'form-control') + = f.label :phone + = f.text_field(:phone, class: 'form-control') + = f.label :fax + = f.text_field(:fax, class: 'form-control') + + .col-md-6.text-left + .form-group + = f.label :ident_type + = f.select :ident_type, options_for_select(Contact::IDENT_TYPES, @contact.ident_type), {}, {class: 'form-control'} + = f.label :ident + = f.text_field(:ident, class: 'form-control') + = f.label :auth_info + = f.text_field(:auth_info, class: 'form-control') + + %hr + .row + .col-md-6.text-left + %h3 + International Address + .form-group + = f.fields_for :international_address do |ia| + = ia.label :name + = ia.text_field(:name, class: 'form-control') + = ia.label :org_name + = ia.text_field(:org_name, class: 'form-control') + + = ia.label :country_id, t(:country) + = ia.collection_select :country_id, Country.all, :id, :name,{}, { class: 'form-control' } + + = ia.label :city + = ia.text_field(:city, class: 'form-control') + = ia.label :street + = ia.text_field(:street, class: 'form-control') + = ia.label :street2 + = ia.text_field(:street2, class: 'form-control') + = ia.label :street3 + = ia.text_field(:street2, class: 'form-control') + + + .col-md-6.text-left + %h3 + Local Address + = f.fields_for :local_address do |ia| + = ia.label :name + = ia.text_field(:name, class: 'form-control') + + = ia.label :country_id, t(:country) + = ia.collection_select :country_id, Country.all, :id, :name,{}, { class: 'form-control' } + + = ia.label :org_name + = ia.text_field(:org_name, class: 'form-control') + + = ia.label :city + = ia.text_field(:city, class: 'form-control') + = ia.label :street + = ia.text_field(:street, class: 'form-control') + = ia.label :street2 + = ia.text_field(:street2, class: 'form-control') + = ia.label :street3 + = ia.text_field(:street2, class: 'form-control') + + .row + .col-md-12.text-right + = button_tag(t('shared.save'), class: 'btn btn-primary') diff --git a/app/views/admin/contacts/edit.haml b/app/views/admin/contacts/edit.haml new file mode 100644 index 000000000..64d31134b --- /dev/null +++ b/app/views/admin/contacts/edit.haml @@ -0,0 +1,9 @@ +.row + .col-sm-6 + %h2.text-center-xs + = "#{t('shared.edit_contact')}" + .col-sm-6 + %h2.text-right.text-center-xs + = link_to(t('shared.back_to_contact'), [:admin, @contact], class: 'btn btn-default') +%hr += render 'form' diff --git a/app/views/admin/contacts/index.haml b/app/views/admin/contacts/index.haml index c920d0bbe..07f3d2c38 100644 --- a/app/views/admin/contacts/index.haml +++ b/app/views/admin/contacts/index.haml @@ -1,6 +1,7 @@ .row .col-sm-6 %h2.text-center-xs= t('shared.contacts') + = render 'admin/contacts/partials/search' .col-sm-6 %h2.text-right.text-center-xs = link_to(t('shared.add'), new_admin_contact_path, class: 'btn btn-primary') diff --git a/app/views/admin/contacts/partials/_search.haml b/app/views/admin/contacts/partials/_search.haml new file mode 100644 index 000000000..645b568f0 --- /dev/null +++ b/app/views/admin/contacts/partials/_search.haml @@ -0,0 +1,6 @@ += search_form_for [:admin, @q] do |f| + = f.search_field :international_address_name_cont + = f.submit do + %span.glyphicon.glyphicon-search + + diff --git a/config/application.rb b/config/application.rb index d3a18e95b..8e4a6a7c2 100644 --- a/config/application.rb +++ b/config/application.rb @@ -13,7 +13,7 @@ require 'sprockets/railtie' # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) -module Internetee +module Registry class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers diff --git a/config/database-example.yml b/config/database-example.yml index 25eeaee5e..37e52ad97 100644 --- a/config/database-example.yml +++ b/config/database-example.yml @@ -3,13 +3,17 @@ default: &default adapter: postgresql encoding: unicode pool: 5 - username: internetee - password: internetee_pwd + username: registry + password: registry_pwd development: <<: *default - database: internetee_development + database: registry_development test: <<: *default - database: internetee_test + database: registry_test + +production: + <<: *default + database: registry_production diff --git a/config/deploy.rb b/config/deploy.rb new file mode 100644 index 000000000..377b6060d --- /dev/null +++ b/config/deploy.rb @@ -0,0 +1,80 @@ +require 'mina/bundler' +require 'mina/rails' +require 'mina/git' +# require 'mina/rbenv' # for rbenv support. (http://rbenv.org) +# require 'mina/rvm' # for rvm support. (http://rvm.io) + +# Basic settings: +# domain - The hostname to SSH to. +# deploy_to - Path to deploy into. +# repository - Git repo to clone from. (needed by mina/git) +# branch - Branch name to deploy. (needed by mina/git) + +set :domain, 'testregistry' +set :deploy_to, '/home/app/registry' +set :repository, 'https://github.com/internetee/registry' +set :branch, 'master' + +# Manually create these paths in shared/ (eg: shared/config/database.yml) in your server. +# They will be linked in the 'deploy:link_shared_paths' step. +set :shared_paths, [ + 'config/database.yml', + 'config/secrets.yml', + 'log', + 'public/system', + 'public/assets' +] + +# Optional settings: +# set :user, 'foobar' # Username in the server to SSH to. +# set :port, '30000' # SSH port number. + +# This task is the environment that is loaded for most commands, such as +# `mina deploy` or `mina rake`. +task :environment do + # If you're using rbenv, use this to load the rbenv environment. + # Be sure to commit your .rbenv-version to your repository. + # invoke :'rbenv:load' + + # For those using RVM, use this to load an RVM version@gemset. + # invoke :'rvm:use[ruby-1.9.3-p125@default]' +end + +# Put any custom mkdir's in here for when `mina setup` is ran. +# For Rails apps, we'll make some of the shared paths that are shared between +# all releases. +task :setup => :environment do + queue! %[mkdir -p "#{deploy_to}/shared/log"] + queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/log"] + + queue! %[mkdir -p "#{deploy_to}/shared/config"] + queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/config"] + + queue! %[touch "#{deploy_to}/shared/config/database.yml"] + queue %[echo "-----> Be sure to edit 'shared/config/database.yml'."] +end + +desc "Deploys the current version to the server." +task :deploy => :environment do + deploy do + # Put things that will set up an empty directory into a fully set-up + # instance of your project. + invoke :'git:clone' + invoke :'deploy:link_shared_paths' + invoke :'bundle:install' + invoke :'rails:db_migrate' + invoke :'rails:assets_precompile' + + to :launch do + queue "mkdir -p #{deploy_to}/current/tmp; touch #{deploy_to}/current/tmp/restart.txt" + end + end +end + +# For help in making your deploy script, see the Mina documentation: +# +# - http://nadarei.co/mina +# - http://nadarei.co/mina/tasks +# - http://nadarei.co/mina/settings +# - http://nadarei.co/mina/helpers + diff --git a/config/initializers/load_validators.rb b/config/initializers/load_validators.rb index 92f534e30..ea84920bf 100644 --- a/config/initializers/load_validators.rb +++ b/config/initializers/load_validators.rb @@ -1 +1 @@ -Internetee::Application.config.autoload_paths += %W(#{Internetee::Application.config.root}/app/validators/) +Registry::Application.config.autoload_paths += %W(#{Registry::Application.config.root}/app/validators/) diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index dbb999454..480996245 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,3 +1,3 @@ # Be sure to restart your server when you modify this file. -Rails.application.config.session_store :cookie_store, key: '_internetee_session' +Rails.application.config.session_store :cookie_store, key: '_registry_session' diff --git a/config/locales/en.yml b/config/locales/en.yml index fd0bdc81c..a6352b9d3 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -265,3 +265,10 @@ en: add_another: 'Add another' domain_updated: 'Domain updated!' failed_to_update_domain: 'Failed to update domain' + failed_to_create_contact: 'Failed to create contact' + contact_deleted: 'Contact deleted' + failed_to_delete_contact: 'Failed to delete contact' + edit_contact: 'Edit contact' + failed_to_update_contact: 'Failed to update contact' + contact_updated: 'Contact updated' + search: 'Search' diff --git a/config/secrets-example.yml b/config/secrets-example.yml index 23fedbe66..9a2adfb5d 100644 --- a/config/secrets-example.yml +++ b/config/secrets-example.yml @@ -5,4 +5,4 @@ test: secret_key_base: generate-your-secret-key-by-rake-secret production: - secret_key_base: + secret_key_base: please-change diff --git a/doc/docker/apache2/epp-tester.conf b/doc/docker/apache2/epp-tester.conf new file mode 100644 index 000000000..140785385 --- /dev/null +++ b/doc/docker/apache2/epp-tester.conf @@ -0,0 +1,18 @@ +Listen 8888 + + ServerName registry.gitlab.eu + ServerAdmin info@gitlab.eu + + PassengerEnabled on + RailsEnv production + DocumentRoot /home/app/epp-tester/current/public + + ErrorLog /var/log/apache2/epp-tester.error.log + LogLevel info ssl:warn + CustomLog /var/log/apache2/epp-tester.access.log combined + + + Require all granted + Options -MultiViews + + diff --git a/doc/docker/apache2/epp.conf b/doc/docker/apache2/epp.conf new file mode 100644 index 000000000..33ef057aa --- /dev/null +++ b/doc/docker/apache2/epp.conf @@ -0,0 +1,21 @@ + + Listen 700 + + SSLEngine on + SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL + SSLCertificateFile /etc/apache2/ssl/apache.crt + SSLCertificateKeyFile /etc/apache2/ssl/apache.key + + SSLVerifyClient optional_no_ca + + EPPEngine On + EPPCommandRoot /proxy/command + EPPSessionRoot /proxy/session + EPPErrorRoot /proxy/error + + ProxyPass /proxy/ http://localhost:80/epp/ + + EPPAuthURI implicit + EPPReturncodeHeader X-EPP-Returncode + + diff --git a/doc/docker/apache2/registry-test.conf b/doc/docker/apache2/registry-test.conf new file mode 100644 index 000000000..dc4b0cc26 --- /dev/null +++ b/doc/docker/apache2/registry-test.conf @@ -0,0 +1,39 @@ +Listen 81 + + ServerAdmin info@gitlab.eu + + PassengerEnabled on + RailsEnv test + DocumentRoot /home/app/registry-test/public + + ErrorLog /var/log/apache2/registry-test.error.log + LogLevel info ssl:warn + CustomLog /var/log/apache2/registry-test.access.log combined + + + Require all granted + Options -MultiViews + + + + + Listen 701 + + SSLEngine on + SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL + SSLCertificateFile /etc/apache2/ssl/apache.crt + SSLCertificateKeyFile /etc/apache2/ssl/apache.key + + SSLVerifyClient optional_no_ca + + EPPEngine On + EPPCommandRoot /proxy/command + EPPSessionRoot /proxy/session + EPPErrorRoot /proxy/error + + ProxyPass /proxy/ http://localhost:81/epp/ + + EPPAuthURI implicit + EPPReturncodeHeader X-EPP-Returncode + + diff --git a/doc/docker/apache2/registry.conf b/doc/docker/apache2/registry.conf new file mode 100644 index 000000000..b01ec745d --- /dev/null +++ b/doc/docker/apache2/registry.conf @@ -0,0 +1,17 @@ + + ServerName registry.gitlab.eu + ServerAdmin info@gitlab.eu + + PassengerEnabled on + RailsEnv production + DocumentRoot /home/app/registry/current/public + + ErrorLog /var/log/apache2/registry.error.log + LogLevel info ssl:warn + CustomLog /var/log/apache2/registry.access.log combined + + + Require all granted + Options -MultiViews + + diff --git a/doc/docker/ssh/authorized_keys b/doc/docker/ssh/authorized_keys new file mode 100755 index 000000000..9266ca452 --- /dev/null +++ b/doc/docker/ssh/authorized_keys @@ -0,0 +1,3 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAz+n4Sln0oxme+9hyrgPud9k0C00Nm0T2YufHcQUAdtJssCfeKp2qo/gy0LmOXTB8efyavFn4NW2GZs8gxJ0BV5GoHLmnERAWDOi/wg3KLl4r/ei+HQX6Po/V7WOMHWzKPSSGtqW7cZc1g0y2ci571ZUmgEBoGoGPfoQToGEn2yV4hQmHIjbwtfNNCHx/i12DCoJnD+3cIvhHf4FbZRBW9Wu0I24iqLcxLOAwGWVsnzi0OqN+rj3DenPQfjcPhSsmTu+8mn2AIwMxWeLZSslEYfyBeo9dLBntj3dnxWpw/MJEfMmWgWKGqMaVGB731ZWDOrRrzgl5+s24YBv9LyYWyQ== +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDXF8qkkQg8We6c2eCRQTuQUAffuDcYijlnVNAH0V7eUMxKC/9aPIhHaM9JVY4exXDVEQOK0+KsF6twTtewK8XBFfHXcOV3k+11KOJ1LsfphQIbwS9Qufw2maxCWJHxQwKGViGLqePuecQhfQ3UAVXZ1ZO7qGrLB9JBlRimbItJsG3F2o1T7pJAMucf+zCv5KmMeeddDyhAg2ufQHnuPKIMAgr4XH/TD4mg5tqORXCdk/2apuqUz35WqAyRNt/J66bTJOJ39QJv50cyT6/Bb74MNfJSejsM5EUnKF4Nq7edR8F8tlnXmL/wvvVs81oHywCnMqP8eEISLumy1nhNpgbn martin@gitlab.eu +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC13V94raEKiCzg4sACsIFxiHPcRSUryUHxXpcyHMi7OJvTtszOPR3hZnB36c0NxnznD0t3rH2n5vIX+tBmX+JND7bvM+YKgTGcGN+HvS08nSsvwHLie/UAHkWy/4xFvyKnq8MIZtYxkPdIGph6hFMr5LljJu05V08hZF09HutBsjXw5wmZRUJoD/Jl0FO/pf6WxH1VHjhz0kGuM8VREU2SC8uzV1AIZ86zsaxJld1m0doyt+arnJkPYgjXHHpu/IWzIHYjbVo5W8JmYagDCYxaPHN7EesHAEzFi1LDtq1aIrqWrczKaJGSryxSba6pnYiK69MTojF/SAXMsJ1u5q1P andres.kesk@gmail.com diff --git a/lib/tasks/test.rake b/lib/tasks/test.rake index cc4a71430..a5999a605 100644 --- a/lib/tasks/test.rake +++ b/lib/tasks/test.rake @@ -1,35 +1,37 @@ -require 'rspec/core/rake_task' -require 'open3' +if Rails.env.test? + require 'rspec/core/rake_task' + require 'open3' -desc 'Run all specs against server' -task 'test' do - test_against_server { Rake::Task['spec'].invoke } -end + desc 'Run all specs against server' + task 'test' do + test_against_server { Rake::Task['spec'].invoke } + end -desc 'Run EPP specs against server' -task 'test:epp' do - test_against_server { Rake::Task['spec:epp'].invoke } -end + desc 'Run EPP specs against server' + task 'test:epp' do + test_against_server { Rake::Task['spec:epp'].invoke } + end -desc 'Run all but EPP specs' -RSpec::Core::RakeTask.new('test:other') do |t| - t.rspec_opts = '--tag ~epp' -end + desc 'Run all but EPP specs' + RSpec::Core::RakeTask.new('test:other') do |t| + t.rspec_opts = '--tag ~epp' + end -desc 'Run all but EPP specs' -RSpec::Core::RakeTask.new('test:all_but_features') do |t| - t.rspec_opts = '--tag ~feature' -end + desc 'Run all but EPP specs' + RSpec::Core::RakeTask.new('test:all_but_features') do |t| + t.rspec_opts = '--tag ~feature' + end -Rake::Task[:default].prerequisites.clear -task default: :test + Rake::Task[:default].prerequisites.clear + task default: :test -def test_against_server - stdin, stdout, stderr, wait_thr = Open3.popen3('unicorn -E test -p 8989') - pid = wait_thr.pid - begin - yield - ensure - `kill #{pid}` + def test_against_server + stdin, stdout, stderr, wait_thr = Open3.popen3('unicorn -E test -p 8989') + pid = wait_thr.pid + begin + yield + ensure + `kill #{pid}` + end end end diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb index 944b8811d..3d89b3038 100644 --- a/spec/models/contact_spec.rb +++ b/spec/models/contact_spec.rb @@ -25,7 +25,9 @@ describe Contact do code: ['Required parameter missing - code'], phone: ['Required parameter missing - phone', 'Phone nr is invalid'], email: ['Required parameter missing - email', 'Email is invalid'], - ident: ['Required parameter missing - ident'] + ident: ['Required parameter missing - ident'], + local_address: ['Local or international address must be present'], + international_address: ['Local or international address must be present'] }) end end