rubocop autocorret to get tests green

This commit is contained in:
Priit Tamboom 2014-10-10 15:10:05 +03:00
parent c0caf53878
commit 2d6ed7fa45
24 changed files with 105 additions and 112 deletions

View file

@ -11,6 +11,7 @@ class Admin::ContactVersionsController < AdminController
end end
private private
def set_contact def set_contact
@contact = Contact.find(params[:id]) @contact = Contact.find(params[:id])
end end

View file

@ -11,6 +11,7 @@ class Admin::DomainVersionsController < AdminController
end end
private private
def set_domain def set_domain
@domain = Domain.find(params[:id]) @domain = Domain.find(params[:id])
end end

View file

@ -27,7 +27,7 @@ class Client::ContactsController < ClientController
redirect_to [:client, @contact] redirect_to [:client, @contact]
else else
flash[:alert] = I18n.t('shared.failed_to_create_contact') flash[:alert] = I18n.t('shared.failed_to_create_contact')
render "new" render 'new'
end end
end end

View file

@ -10,8 +10,7 @@ class SessionsController < Devise::SessionsController
session[:current_user_registrar_id] = Registrar.first.id if @user.admin? session[:current_user_registrar_id] = Registrar.first.id if @user.admin?
flash[:notice] = I18n.t('shared.welcome') flash[:notice] = I18n.t('shared.welcome')
sign_in_and_redirect @user, :event => :authentication sign_in_and_redirect @user, event: :authentication
return
# end # end
end end

View file

@ -1,5 +1,5 @@
module ApplicationHelper module ApplicationHelper
def coffee_script_tag(&block) def coffee_script_tag(&block)
content_tag(:script, CoffeeScript.compile(capture(&block)).html_safe, :type => 'text/javascript') content_tag(:script, CoffeeScript.compile(capture(&block)).html_safe, type: 'text/javascript')
end end
end end

View file

@ -7,12 +7,12 @@ module Epp::DomainsHelper
if @domain.errors.any? if @domain.errors.any?
handle_errors(@domain) handle_errors(@domain)
raise ActiveRecord::Rollback and return fail ActiveRecord::Rollback and return
end end
unless @domain.save unless @domain.save
handle_errors(@domain) handle_errors(@domain)
raise ActiveRecord::Rollback and return fail ActiveRecord::Rollback and return
end end
render '/epp/domains/create' render '/epp/domains/create'
@ -55,12 +55,12 @@ module Epp::DomainsHelper
if @domain.errors.any? if @domain.errors.any?
handle_errors(@domain) handle_errors(@domain)
raise ActiveRecord::Rollback and return fail ActiveRecord::Rollback and return
end end
unless @domain.save unless @domain.save
handle_errors(@domain) handle_errors(@domain)
raise ActiveRecord::Rollback and return fail ActiveRecord::Rollback and return
end end
render '/epp/domains/success' render '/epp/domains/success'

View file

@ -2,8 +2,7 @@ class Ability
include CanCan::Ability include CanCan::Ability
def initialize(user) def initialize(user)
alias_action :create, :read, :update, :destroy, to: :crud
alias_action :create, :read, :update, :destroy, :to => :crud
user ||= User.new user ||= User.new

View file

@ -37,7 +37,7 @@ module EppErrors
epp_errors = [] epp_errors = []
send(key).each do |x| send(key).each do |x|
x.errors.messages.each do |key, values| x.errors.messages.each do |_key, values|
epp_errors << x.collect_parent_errors(values) epp_errors << x.collect_parent_errors(values)
end end
end if multi.include?(macro) end if multi.include?(macro)

View file

@ -18,7 +18,5 @@ module UserEvents
def epp_user_events(id) def epp_user_events(id)
where(whodunnit: "#{id}-EppUser") where(whodunnit: "#{id}-EppUser")
end end
end end
end end

View file

@ -97,7 +97,6 @@ class Contact < ActiveRecord::Base
# should use only in transaction # should use only in transaction
def destroy_and_clean def destroy_and_clean
if relations_with_domain? if relations_with_domain?
errors.add(:domains, :exist) errors.add(:domains, :exist)
return false return false

View file

@ -5,5 +5,4 @@ class ContactVersion < PaperTrail::Version
self.table_name = :contact_versions self.table_name = :contact_versions
self.sequence_name = :contact_version_id_seq self.sequence_name = :contact_version_id_seq
end end

View file

@ -118,7 +118,7 @@ class Domain < ActiveRecord::Base
def validate_nameserver_ips def validate_nameserver_ips
nameservers.each do |ns| nameservers.each do |ns|
next if !ns.hostname.end_with?(name) next unless ns.hostname.end_with?(name)
next if ns.ipv4.present? next if ns.ipv4.present?
errors.add(:nameservers, :invalid) if errors[:nameservers].blank? errors.add(:nameservers, :invalid) if errors[:nameservers].blank?
ns.errors.add(:ipv4, :blank) ns.errors.add(:ipv4, :blank)

View file

@ -71,7 +71,7 @@ class Epp::EppDomain < Domain
# TODO: Find out if there are any attributes that can be changed # TODO: Find out if there are any attributes that can be changed
# if not, delete this method # if not, delete this method
def parse_and_update_domain_attributes(parsed_frame) def parse_and_update_domain_attributes(_parsed_frame)
# assign_attributes(self.class.parse_update_params_from_frame(parsed_frame)) # assign_attributes(self.class.parse_update_params_from_frame(parsed_frame))
errors.empty? errors.empty?

View file

@ -1,14 +1,13 @@
class Registrar < ActiveRecord::Base class Registrar < ActiveRecord::Base
belongs_to :country belongs_to :country
has_many :domains, :dependent => :restrict_with_error has_many :domains, dependent: :restrict_with_error
has_many :contacts, :dependent => :restrict_with_error has_many :contacts, dependent: :restrict_with_error
has_many :epp_users, :dependent => :restrict_with_error has_many :epp_users, dependent: :restrict_with_error
has_many :users, :dependent => :restrict_with_error has_many :users, dependent: :restrict_with_error
validates :name, :reg_no, :address, :country, presence: true validates :name, :reg_no, :address, :country, presence: true
validates :name, :reg_no, uniqueness: true validates :name, :reg_no, uniqueness: true
def domain_transfers def domain_transfers
at = DomainTransfer.arel_table at = DomainTransfer.arel_table
DomainTransfer.where( DomainTransfer.where(

View file

@ -66,10 +66,10 @@ Rails.application.routes.draw do
end end
authenticated :user do authenticated :user do
root :to => 'admin/domains#index', :as => :authenticated_root root to: 'admin/domains#index', as: :authenticated_root
end end
root :to => redirect('login') root to: redirect('login')
# The priority is based upon order of creation: first created -> highest priority. # The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes". # See how all your routes lay out with "rake routes".

View file

@ -2,9 +2,9 @@ desc 'Commands for whois'
desc 'generate whois files' desc 'generate whois files'
task 'whois:generate' => :environment do task 'whois:generate' => :environment do
Dir.mkdir("./tmp/whois") unless File.exists?("./tmp/whois") #a folder for ze stuff Dir.mkdir('./tmp/whois') unless File.exist?('./tmp/whois') # a folder for ze stuff
alphabet = (("a".."z").to_a << %w(ö õ ü ä) ).flatten! alphabet = (('a'..'z').to_a << %w(ö õ ü ä)).flatten!
@domains = {} @domains = {}
alphabet.each do |letter| alphabet.each do |letter|
domains = Domain.where(['name LIKE ?', "#{letter}%"]) domains = Domain.where(['name LIKE ?', "#{letter}%"])
@ -27,4 +27,3 @@ task 'whois:generate' => :environment do
end end
end end

View file

@ -273,7 +273,7 @@ describe 'EPP Domain', epp: true do
xml = domain_create_xml({ xml = domain_create_xml({
ns: [ ns: [
{ hostObj: { value: 'invalid1-' } }, { hostObj: { value: 'invalid1-' } },
{ hostObj: { value: '-invalid2' } }, { hostObj: { value: '-invalid2' } }
] ]
}) })
@ -580,12 +580,12 @@ describe 'EPP Domain', epp: true do
expect(inf_data.css('status').first[:s]).to eq('clientHold') expect(inf_data.css('status').first[:s]).to eq('clientHold')
expect(inf_data.css('registrant').text).to eq(d.owner_contact_code) expect(inf_data.css('registrant').text).to eq(d.owner_contact_code)
admin_contacts_from_request = inf_data.css('contact[type="admin"]').map { |x| x.text } admin_contacts_from_request = inf_data.css('contact[type="admin"]').map(&:text)
admin_contacts_existing = d.admin_contacts.pluck(:code) admin_contacts_existing = d.admin_contacts.pluck(:code)
expect(admin_contacts_from_request).to eq(admin_contacts_existing) expect(admin_contacts_from_request).to eq(admin_contacts_existing)
hosts_from_request = inf_data.css('hostObj').map { |x| x.text } hosts_from_request = inf_data.css('hostObj').map(&:text)
hosts_existing = d.nameservers.where(ipv4: nil).pluck(:hostname) hosts_existing = d.nameservers.where(ipv4: nil).pluck(:hostname)
expect(hosts_from_request).to eq(hosts_existing) expect(hosts_from_request).to eq(hosts_existing)

View file

@ -452,7 +452,6 @@ describe 'EPP Helper', epp: true do
generated = Nokogiri::XML(domain_delete_xml).to_s.squish generated = Nokogiri::XML(domain_delete_xml).to_s.squish
expect(generated).to eq(expected) expect(generated).to eq(expected)
expected = Nokogiri::XML('<?xml version="1.0" encoding="UTF-8" standalone="no"?> expected = Nokogiri::XML('<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0"> <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command> <command>