Skip to content

Instantly share code, notes, and snippets.

View abacha's full-sized avatar

Adriano Bacha abacha

  • São Paulo, SP
  • 23:08 (UTC -03:00)
View GitHub Profile
scenario "updating email", js: true, focus: true do
person = create(:person)
login_as create(:user, role: "Operacional")
visit "/people"
find(:xpath, '//*[@id="body"]/table/tbody/tr[1]/td[6]/a[2]').click
within "#edit_email" do
fill_in "Email", with: "[email protected]"
click_on "Salvar"
scenario "upload with errors", js: true do
filepath = "#{Rails.root}/spec/fixtures/transactions_with_errors.xls"
puts File.exists?(filepath) #true
attach_file "transactions_spreadsheet", filepath
click_on "Enviar"
save_and_open_page
end
# encoding: utf-8
require 'spec_helper'
feature "accounts" do
given(:person) { create(:person).decorate }
background { login_as(person.user) }
scenario "creating individual account" do
visit "/accounts/new"
def mail
if !activity_type.public || activity_type.private_fields.count > 0
ActivityMailer.delay.report(id, true)
end
if activity_type.public
public_fields = self.values.select { |value| value.field.public && !value.blank? }
ActivityMailer.delay.report(id, false) unless public_fields.empty?
end
end
config.before(:all) do
ActiveRecord::Schema.verbose = false
load_schema = lambda {
load "#{Rails.root.to_s}/db/schema.rb"
# ActiveRecord::Migrator.up('db/migrate') # use migrations
}
silence_stream(STDOUT, &load_schema)
end
test: &test
adapter: sqlite3
encoding: utf8
database: ":memory:"
class MoveFundGroupFromFundsToCrawlers < ActiveRecord::Migration
def change
add_column :crawlers, :fund_group, :integer
Fund.all.each do |fund|
fund.crawler.update_attributes(:fund_group => fund.fund_group) if fund.fund_group && !fund.crawler.nil?
end
remove_column :funds, :fund_group
end
end
if activity.activitable.is_a? Account
restricted_mail = ["[email protected]"]
alias :reporter :account_report
elsif activity.activitable.is_a? Manager
restricted_mail = ["[email protected]"]
alias :reporter :manager_report
end
reporter(activity, to, false)
def report(activity)
if activity.activitable.is_a? Account
account_report(activity)
elsif activity.activitable.is_a? Manager
manager_report(activity)
end
end
oldest = {}
transactions.each do |transaction|
oldest[transaction.account_id] ||= {}
oldest[transaction.account_id][transaction.fund_id] ||= transaction
if transaction.value_date < oldest[transaction.account_id][transaction.fund_id].value_date
oldest[transaction.account_id][transaction.fund_id] = transaction
end
transaction.save
end