Some new rubocop checks.

This commit is contained in:
Martin Edenhofer 2015-04-27 22:49:17 +02:00
parent c694f2f37e
commit 60121a25fb
13 changed files with 167 additions and 175 deletions

View file

@ -171,7 +171,7 @@ class ApplicationController < ActionController::Base
} }
end end
return { {
auth: true auth: true
} }
end end

View file

@ -173,7 +173,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
end end
# check domain based attributes # check domain based attributes
providerMap = { provider_map = {
google: { google: {
domain: 'gmail.com|googlemail.com|gmail.de', domain: 'gmail.com|googlemail.com|gmail.de',
inbound: { inbound: {
@ -231,7 +231,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
if mail_exchangers && mail_exchangers[0] && mail_exchangers[0][0] if mail_exchangers && mail_exchangers[0] && mail_exchangers[0][0]
domains.push mail_exchangers[0][0] domains.push mail_exchangers[0][0]
end end
providerMap.each {|provider, settings| provider_map.each {|provider, settings|
domains.each {|domain_to_check| domains.each {|domain_to_check|
if domain_to_check =~ /#{settings[:domain]}/i if domain_to_check =~ /#{settings[:domain]}/i
@ -259,9 +259,9 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
} }
# probe inbound # probe inbound
inboundMap = [] inbound_map = []
if mail_exchangers && mail_exchangers[0] && mail_exchangers[0][0] if mail_exchangers && mail_exchangers[0] && mail_exchangers[0][0]
inboundMx = [ inbound_mx = [
{ {
adapter: 'imap', adapter: 'imap',
options: { options: {
@ -283,9 +283,9 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
}, },
}, },
] ]
inboundMap = inboundMap + inboundMx inbound_map = inbound_map + inbound_mx
end end
inboundAuto = [ inbound_auto = [
{ {
adapter: 'imap', adapter: 'imap',
options: { options: {
@ -387,10 +387,10 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
}, },
}, },
] ]
inboundMap = inboundMap + inboundAuto inbound_map = inbound_map + inbound_auto
settings = {} settings = {}
success = false success = false
inboundMap.each {|config| inbound_map.each {|config|
logger.info "INBOUND PROBE: #{config.inspect}" logger.info "INBOUND PROBE: #{config.inspect}"
result = email_probe_inbound( config ) result = email_probe_inbound( config )
logger.info "INBOUND RESULT: #{result.inspect}" logger.info "INBOUND RESULT: #{result.inspect}"
@ -409,9 +409,9 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
end end
# probe outbound # probe outbound
outboundMap = [] outbound_map = []
if mail_exchangers && mail_exchangers[0] && mail_exchangers[0][0] if mail_exchangers && mail_exchangers[0] && mail_exchangers[0][0]
outboundMx = [ outbound_mx = [
{ {
adapter: 'smtp', adapter: 'smtp',
options: { options: {
@ -453,9 +453,9 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
}, },
}, },
] ]
outboundMap = outboundMap + outboundMx outbound_map = outbound_map + outbound_mx
end end
outboundAuto = [ outbound_auto = [
{ {
adapter: 'smtp', adapter: 'smtp',
options: { options: {
@ -539,7 +539,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
] ]
success = false success = false
outboundMap.each {|config| outbound_map.each {|config|
logger.info "OUTBOUND PROBE: #{config.inspect}" logger.info "OUTBOUND PROBE: #{config.inspect}"
result = email_probe_outbound( config, params[:email] ) result = email_probe_outbound( config, params[:email] )
logger.info "OUTBOUND RESULT: #{result.inspect}" logger.info "OUTBOUND RESULT: #{result.inspect}"
@ -599,7 +599,6 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
result = email_probe_inbound( params ) result = email_probe_inbound( params )
render json: result render json: result
return
end end
def email_verify def email_verify
@ -737,7 +736,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
end end
# test connection # test connection
translationMap = { translation_map = {
'authentication failed' => 'Authentication failed!', 'authentication failed' => 'Authentication failed!',
'Incorrect username' => 'Authentication failed!', 'Incorrect username' => 'Authentication failed!',
'getaddrinfo: nodename nor servname provided, or not known' => 'Hostname not found!', 'getaddrinfo: nodename nor servname provided, or not known' => 'Hostname not found!',
@ -747,10 +746,10 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
if params[:adapter] =~ /^smtp$/i if params[:adapter] =~ /^smtp$/i
# in case, fill missing params # in case, fill missing params
if !params[:options].has_key?(:port) if !params[:options].key?(:port)
params[:options][:port] = 25 params[:options][:port] = 25
end end
if !params[:options].has_key?(:ssl) if !params[:options].key?(:ssl)
params[:options][:ssl] = true params[:options][:ssl] = true
end end
@ -765,10 +764,10 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
# check if sending email was ok, but mailserver rejected # check if sending email was ok, but mailserver rejected
if !subject if !subject
whiteMap = { white_map = {
'Recipient address rejected' => true, 'Recipient address rejected' => true,
} }
whiteMap.each {|key, message| white_map.each {|key, message|
if e.message =~ /#{Regexp.escape(key)}/i if e.message =~ /#{Regexp.escape(key)}/i
result = { result = {
result: 'ok', result: 'ok',
@ -780,7 +779,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
} }
end end
message_human = '' message_human = ''
translationMap.each {|key, message| translation_map.each {|key, message|
if e.message =~ /#{Regexp.escape(key)}/i if e.message =~ /#{Regexp.escape(key)}/i
message_human = message message_human = message
end end
@ -806,7 +805,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
) )
rescue Exception => e rescue Exception => e
message_human = '' message_human = ''
translationMap.each {|key, message| translation_map.each {|key, message|
if e.message =~ /#{Regexp.escape(key)}/i if e.message =~ /#{Regexp.escape(key)}/i
message_human = message message_human = message
end end
@ -822,7 +821,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
result = { result = {
result: 'ok', result: 'ok',
} }
return result result
end end
def email_probe_inbound(params) def email_probe_inbound(params)
@ -833,7 +832,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
end end
# connection test # connection test
translationMap = { translation_map = {
'authentication failed' => 'Authentication failed!', 'authentication failed' => 'Authentication failed!',
'Incorrect username' => 'Authentication failed!', 'Incorrect username' => 'Authentication failed!',
'getaddrinfo: nodename nor servname provided, or not known' => 'Hostname not found!', 'getaddrinfo: nodename nor servname provided, or not known' => 'Hostname not found!',
@ -846,7 +845,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
Channel::IMAP.new.fetch( { options: params[:options] }, 'check' ) Channel::IMAP.new.fetch( { options: params[:options] }, 'check' )
rescue Exception => e rescue Exception => e
message_human = '' message_human = ''
translationMap.each {|key, message| translation_map.each {|key, message|
if e.message =~ /#{Regexp.escape(key)}/i if e.message =~ /#{Regexp.escape(key)}/i
message_human = message message_human = message
end end
@ -869,7 +868,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
Channel::POP3.new.fetch( { options: params[:options] }, 'check' ) Channel::POP3.new.fetch( { options: params[:options] }, 'check' )
rescue Exception => e rescue Exception => e
message_human = '' message_human = ''
translationMap.each {|key, message| translation_map.each {|key, message|
if e.message =~ /#{Regexp.escape(key)}/i if e.message =~ /#{Regexp.escape(key)}/i
message_human = message message_human = message
end end
@ -885,7 +884,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
result = { result = {
result: 'ok', result: 'ok',
} }
return result result
end end
def mxers(domain) def mxers(domain)

View file

@ -29,7 +29,7 @@ class LongPollingController < ApplicationController
# error handling # error handling
if params['data']['timestamp'] if params['data']['timestamp']
log 'notice', "request spool data > '#{Time.at( params['data']['timestamp'] ).to_s}'", client_id log 'notice', "request spool data > '#{Time.at( params['data']['timestamp'] )}'", client_id
else else
log 'notice', 'request spool init data', client_id log 'notice', 'request spool init data', client_id
end end
@ -75,13 +75,13 @@ class LongPollingController < ApplicationController
if params['data']['recipient'] && params['data']['recipient']['user_id'] if params['data']['recipient'] && params['data']['recipient']['user_id']
params['data']['recipient']['user_id'].each { |user_id| params['data']['recipient']['user_id'].each { |user_id|
if local_client[:user]['id'].to_s == user_id.to_s if local_client[:user]['id'].to_s == user_id.to_s
log 'notice', "send broadcast from (#{client_id.to_s}) to (user_id #{user_id})", local_client_id log 'notice', "send broadcast from (#{client_id}) to (user_id #{user_id})", local_client_id
Sessions.send( local_client_id, params['data'] ) Sessions.send( local_client_id, params['data'] )
end end
} }
# broadcast every client # broadcast every client
else else
log 'notice', "send broadcast from (#{client_id.to_s})", local_client_id log 'notice', "send broadcast from (#{client_id})", local_client_id
Sessions.send( local_client_id, params['data'] ) Sessions.send( local_client_id, params['data'] )
end end
else else
@ -124,7 +124,7 @@ class LongPollingController < ApplicationController
count = count - 1 count = count - 1
queue = Sessions.queue( client_id ) queue = Sessions.queue( client_id )
if queue && queue[0] if queue && queue[0]
# puts "send " + queue.inspect + client_id.to_s # puts "send " + queue.inspect + client_id.to_s
render json: queue render json: queue
return return
end end
@ -155,14 +155,14 @@ class LongPollingController < ApplicationController
return if !params[:client_id] return if !params[:client_id]
sessions = Sessions.sessions sessions = Sessions.sessions
return if !sessions.include?( params[:client_id].to_s ) return if !sessions.include?( params[:client_id].to_s )
return params[:client_id].to_s params[:client_id].to_s
end end
def log( level, data, client_id = '-' ) def log( level, data, client_id = '-' )
if false if false
return if level == 'debug' return if level == 'debug'
end end
puts "#{Time.now}:client(#{ client_id }) #{ data }" puts "#{Time.zone.now}:client(#{ client_id }) #{ data }"
# puts "#{Time.now}:#{ level }:client(#{ client_id }) #{ data }" # puts "#{Time.now}:#{ level }:client(#{ client_id }) #{ data }"
end end
end end

View file

@ -32,7 +32,7 @@ class TagsController < ApplicationController
object: params[:object], object: params[:object],
o_id: params[:o_id], o_id: params[:o_id],
item: params[:item], item: params[:item],
); )
if success if success
render json: success, status: :created render json: success, status: :created
else else
@ -46,7 +46,7 @@ class TagsController < ApplicationController
object: params[:object], object: params[:object],
o_id: params[:o_id], o_id: params[:o_id],
item: params[:item], item: params[:item],
); )
if success if success
render json: success, status: :created render json: success, status: :created
else else

View file

@ -38,11 +38,12 @@ class TaskbarController < ApplicationController
end end
private private
def access(taskbar) def access(taskbar)
if taskbar.user_id != current_user.id if taskbar.user_id != current_user.id
render json: { error: 'Not allowed to access this task.' }, status: :unprocessable_entity render json: { error: 'Not allowed to access this task.' }, status: :unprocessable_entity
return false return false
end end
return true true
end end
end end

View file

@ -360,7 +360,7 @@ class TicketsController < ApplicationController
limit = 100 limit = 100
assets = {} assets = {}
access_condition = Ticket.access_condition( current_user ) access_condition = Ticket.access_condition( current_user )
now = DateTime.now now = Time.zone.now
user_tickets_open_ids = [] user_tickets_open_ids = []
user_tickets_closed_ids = [] user_tickets_closed_ids = []
user_ticket_volume_by_year = [] user_ticket_volume_by_year = []
@ -395,8 +395,8 @@ class TicketsController < ApplicationController
# generate stats by user # generate stats by user
(0..11).each {|month_back| (0..11).each {|month_back|
date_to_check = DateTime.now - month_back.month date_to_check = Time.zone.now - month_back.month
date_start = "#{date_to_check.year}-#{date_to_check.month}-#{01} 00:00:00" date_start = "#{date_to_check.year}-#{date_to_check.month}-01 00:00:00"
date_end = "#{date_to_check.year}-#{date_to_check.month}-#{date_to_check.end_of_month.day} 00:00:00" date_end = "#{date_to_check.year}-#{date_to_check.month}-#{date_to_check.end_of_month.day} 00:00:00"
condition = { condition = {
@ -463,7 +463,7 @@ class TicketsController < ApplicationController
# generate stats by org # generate stats by org
(0..11).each {|month_back| (0..11).each {|month_back|
date_to_check = DateTime.now - month_back.month date_to_check = DateTime.now - month_back.month
date_start = "#{date_to_check.year}-#{date_to_check.month}-#{01} 00:00:00" date_start = "#{date_to_check.year}-#{date_to_check.month}-01 00:00:00"
date_end = "#{date_to_check.year}-#{date_to_check.month}-#{date_to_check.end_of_month.day} 00:00:00" date_end = "#{date_to_check.year}-#{date_to_check.month}-#{date_to_check.end_of_month.day} 00:00:00"
condition = { condition = {
@ -507,7 +507,7 @@ class TicketsController < ApplicationController
ticket_ids.push ticket.id ticket_ids.push ticket.id
assets = ticket.assets(assets) assets = ticket.assets(assets)
end end
return ticket_ids ticket_ids
end end
def article_create(ticket, params) def article_create(ticket, params)

View file

@ -644,7 +644,7 @@ curl http://localhost/api/v1/users/avatar -v -u #{login}:#{password} -H "Content
content: file_resize[:content], content: file_resize[:content],
mime_type: file_resize[:mime_type], mime_type: file_resize[:mime_type],
}, },
source: 'upload ' + Time.now.to_s, source: 'upload ' + Time.zone.now.to_s,
deletable: true, deletable: true,
) )
@ -719,7 +719,7 @@ curl http://localhost/api/v1/users/avatar -v -u #{login}:#{password} -H "Content
return true if is_role('Agent') return true if is_role('Agent')
response_access_deny response_access_deny
return false false
end end
def permission_check def permission_check
@ -730,7 +730,7 @@ curl http://localhost/api/v1/users/avatar -v -u #{login}:#{password} -H "Content
return true if is_role(Z_ROLENAME_CUSTOMER) && params[:id].to_i == current_user.id return true if is_role(Z_ROLENAME_CUSTOMER) && params[:id].to_i == current_user.id
response_access_deny response_access_deny
return false false
end end
end end

View file

@ -1,6 +1,7 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
module User::Permission module User
module Permission
=begin =begin
@ -15,22 +16,22 @@ returns
=end =end
def permission (data) def permission (data)
# check customer # check customer
if data[:current_user].is_role(Z_ROLENAME_CUSTOMER) if data[:current_user].is_role(Z_ROLENAME_CUSTOMER)
# access ok if its own user # access ok if its own user
return true if self.id == data[:current_user].id return true if self.id == data[:current_user].id
# no access # no access
return false return false
end
# check agent
return true if data[:current_user].is_role(Z_ROLENAME_ADMIN)
return true if data[:current_user].is_role('Agent')
false
end end
# check agent
return true if data[:current_user].is_role(Z_ROLENAME_ADMIN)
return true if data[:current_user].is_role('Agent')
false
end end
end end

View file

@ -1,6 +1,7 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
module User::Search module User
module Search
=begin =begin
@ -18,39 +19,39 @@ returns
=end =end
def search(params) def search(params)
# get params # get params
query = params[:query] query = params[:query]
limit = params[:limit] || 10 limit = params[:limit] || 10
current_user = params[:current_user] current_user = params[:current_user]
# enable search only for agents and admins # enable search only for agents and admins
return [] if !current_user.is_role('Agent') && !current_user.is_role(Z_ROLENAME_ADMIN) return [] if !current_user.is_role('Agent') && !current_user.is_role(Z_ROLENAME_ADMIN)
# try search index backend # try search index backend
if SearchIndexBackend.enabled? if SearchIndexBackend.enabled?
items = SearchIndexBackend.search( query, limit, 'User' ) items = SearchIndexBackend.search( query, limit, 'User' )
users = [] users = []
items.each { |item| items.each { |item|
users.push User.lookup( id: item[:id] ) users.push User.lookup( id: item[:id] )
} }
return users return users
end
# fallback do sql query
# - stip out * we already search for *query* -
query.gsub! '*', ''
if params[:role_ids]
users = User.joins(:roles).where( 'roles.id' => params[:role_ids] ).where(
'(users.firstname LIKE ? or users.lastname LIKE ? or users.email LIKE ?) AND users.id != 1', "%#{query}%", "%#{query}%", "%#{query}%",
).order('firstname').limit(limit)
else
users = User.where(
'(firstname LIKE ? or lastname LIKE ? or email LIKE ?) AND id != 1', "%#{query}%", "%#{query}%", "%#{query}%",
).order('firstname').limit(limit)
end
users
end end
# fallback do sql query
# - stip out * we already search for *query* -
query.gsub! '*', ''
if params[:role_ids]
users = User.joins(:roles).where( 'roles.id' => params[:role_ids] ).where(
'(users.firstname LIKE ? or users.lastname LIKE ? or users.email LIKE ?) AND users.id != 1', "%#{query}%", "%#{query}%", "%#{query}%",
).order('firstname').limit(limit)
else
users = User.where(
'(firstname LIKE ? or lastname LIKE ? or email LIKE ?) AND id != 1', "%#{query}%", "%#{query}%", "%#{query}%",
).order('firstname').limit(limit)
end
users
end end
end end

View file

@ -1,6 +1,7 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
module User::SearchIndex module User
module SearchIndex
=begin =begin
@ -15,14 +16,15 @@ returns
=end =end
def search_index_data def search_index_data
attributes = { 'fullname' => "#{ self['firstname'] } #{ self['lastname'] }" } attributes = { 'fullname' => "#{ self['firstname'] } #{ self['lastname'] }" }
['login', 'firstname', 'lastname', 'phone', 'email', 'city', 'country', 'note', 'created_at'].each { |key| ['login', 'firstname', 'lastname', 'phone', 'email', 'city', 'country', 'note', 'created_at'].each { |key|
if self[key] && (!self.respond_to?('empty?') || !self[key].empty?) if self[key] && (!self.respond_to?('empty?') || !self[key].empty?)
attributes[key] = self[key] attributes[key] = self[key]
end end
} }
return if attributes.empty? return if attributes.empty?
attributes attributes
end
end end
end end

View file

@ -220,9 +220,7 @@ class TestCase < Test::Unit::TestCase
else else
instance.find_elements( { partial_link_text: params[:text] } )[0].click instance.find_elements( { partial_link_text: params[:text] } )[0].click
end end
if !params[:fast] sleep 0.4 if !params[:fast]
sleep 0.4
end
end end
=begin =begin
@ -357,9 +355,7 @@ class TestCase < Test::Unit::TestCase
element = instance.find_elements( { css: params[:css] } )[0] element = instance.find_elements( { css: params[:css] } )[0]
checked = element.attribute('checked') checked = element.attribute('checked')
if !checked element.click if !checked
element.click
end
end end
=begin =begin
@ -378,9 +374,7 @@ class TestCase < Test::Unit::TestCase
element = instance.find_elements( { css: params[:css] } )[0] element = instance.find_elements( { css: params[:css] } )[0]
checked = element.attribute('checked') checked = element.attribute('checked')
if checked element.click if checked
element.click
end
end end
=begin =begin
@ -760,8 +754,6 @@ class TestCase < Test::Unit::TestCase
sleep 0.5 sleep 0.5
return true return true
end end
rescue
# just try again
end end
end end
sleep 0.5 sleep 0.5
@ -816,8 +808,6 @@ wait untill text in selector disabppears
sleep 1 sleep 1
return true return true
end end
rescue
# just try again
end end
end end
sleep 1 sleep 1
@ -839,7 +829,7 @@ wait untill text in selector disabppears
instance = params[:browser] || @browser instance = params[:browser] || @browser
for i in 1..100 (1..100).each do
sleep 1 sleep 1
begin begin
if instance.find_elements( { css: '.navigation .tasks .task:first-child' } )[0] if instance.find_elements( { css: '.navigation .tasks .task:first-child' } )[0]
@ -860,8 +850,6 @@ wait untill text in selector disabppears
else else
break break
end end
rescue
# just try again
end end
end end
sleep 1 sleep 1
@ -1047,7 +1035,7 @@ wait untill text in selector disabppears
sleep 2.5 sleep 2.5
id = instance.current_url id = instance.current_url
id.gsub!(//, ) id.gsub!(//, )
id.gsub!(/^.+?\/(\d+)$/, '\\1') id.gsub!(%r{^.+?/(\d+)$}, '\\1')
element = instance.find_elements( { css: '.active .page-header .ticket-number' } )[0] element = instance.find_elements( { css: '.active .page-header .ticket-number' } )[0]
if element if element
@ -1100,18 +1088,18 @@ wait untill text in selector disabppears
instance.execute_script( '$(".content.active .page-header .ticket-title-update").text("' + data[:title] + '")' ) instance.execute_script( '$(".content.active .page-header .ticket-title-update").text("' + data[:title] + '")' )
instance.execute_script( '$(".content.active .page-header .ticket-title-update").blur()' ) instance.execute_script( '$(".content.active .page-header .ticket-title-update").blur()' )
instance.execute_script( '$(".content.active .page-header .ticket-title-update").trigger("blur")' ) instance.execute_script( '$(".content.active .page-header .ticket-title-update").trigger("blur")' )
# { # {
# :where => :instance2, # :where => :instance2,
# :execute => 'sendkey', # :execute => 'sendkey',
# :css => '.content.active .page-header .ticket-title-update', # :css => '.content.active .page-header .ticket-title-update',
# :value => 'TTT', # :value => 'TTT',
# }, # },
# { # {
# :where => :instance2, # :where => :instance2,
# :execute => 'sendkey', # :execute => 'sendkey',
# :css => '.content.active .page-header .ticket-title-update', # :css => '.content.active .page-header .ticket-title-update',
# :value => :tab, # :value => :tab,
# }, # },
end end
if data[:customer] if data[:customer]
@ -1203,8 +1191,6 @@ wait untill text in selector disabppears
if text =~ /(Discard your unsaved changes.|Verwerfen der)/ if text =~ /(Discard your unsaved changes.|Verwerfen der)/
found = true found = true
end end
rescue
# just try again
end end
sleep 1 sleep 1
end end
@ -1227,8 +1213,6 @@ wait untill text in selector disabppears
if !text || text.empty? if !text || text.empty?
return true return true
end end
rescue
# just try again
end end
sleep 1 sleep 1
} }
@ -1374,7 +1358,7 @@ wait untill text in selector disabppears
overviews = {} overviews = {}
instance.find_elements( { css: '.content.active .sidebar a[href]' } ).each {|element| instance.find_elements( { css: '.content.active .sidebar a[href]' } ).each {|element|
url = element.attribute('href') url = element.attribute('href')
url.gsub!(/(http|https):\/\/.+?\/(.+?)$/, '\\2') url.gsub!(%r{(http|https)://.+?/(.+?)$}, '\\2')
overviews[url] = 0 overviews[url] = 0
#puts url.inspect #puts url.inspect
#puts element.inspect #puts element.inspect

View file

@ -3,25 +3,27 @@ require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help' require 'rails/test_help'
require 'cache' require 'cache'
class ActiveSupport::TestCase module ActiveSupport
# disable transactions class TestCase
#self.use_transactional_fixtures = false # disable transactions
#self.use_transactional_fixtures = false
# clear cache
Cache.clear
# load seeds
load "#{Rails.root}/db/seeds.rb"
setup do
# clear cache # clear cache
Cache.clear Cache.clear
# set current user # load seeds
puts 'reset UserInfo.current_user_id' load "#{Rails.root}/db/seeds.rb"
UserInfo.current_user_id = nil
end
# Add more helper methods to be used by all tests here... setup do
# clear cache
Cache.clear
# set current user
puts 'reset UserInfo.current_user_id'
UserInfo.current_user_id = nil
end
# Add more helper methods to be used by all tests here...
end
end end

View file

@ -5,36 +5,38 @@ require 'cache'
require 'simplecov' require 'simplecov'
require 'simplecov-rcov' require 'simplecov-rcov'
class ActiveSupport::TestCase module ActiveSupport
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. class TestCase
# # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
# Note: You'll currently still have to declare fixtures explicitly in integration tests #
# -- they do not yet inherit this setting # Note: You'll currently still have to declare fixtures explicitly in integration tests
SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter # -- they do not yet inherit this setting
SimpleCov.start SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
fixtures :all SimpleCov.start
fixtures :all
# disable transactions # disable transactions
self.use_transactional_fixtures = false self.use_transactional_fixtures = false
# clear cache
Cache.clear
# load seeds
load "#{Rails.root}/db/seeds.rb"
# set system mode to done / to activate
Setting.set('system_init_done', true)
setup do
# clear cache # clear cache
Cache.clear Cache.clear
# set current user # load seeds
puts 'reset UserInfo.current_user_id' load "#{Rails.root}/db/seeds.rb"
UserInfo.current_user_id = nil
end
# Add more helper methods to be used by all tests here... # set system mode to done / to activate
Setting.set('system_init_done', true)
setup do
# clear cache
Cache.clear
# set current user
puts 'reset UserInfo.current_user_id'
UserInfo.current_user_id = nil
end
# Add more helper methods to be used by all tests here...
end
end end