Skip to content

Instantly share code, notes, and snippets.

Gems:
event_calendar
devise
cancan
+ не нашел date_picker как гема, поэтому реализую jquery плагин
Models:
Event
@arturdent
arturdent / index
Created March 30, 2012 03:31
popup
<!doctype html>
<html>
<head>
<meta charset='utf-8'>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>Popup Model</title>
<link rel="stylesheet" href="style.css">
<!--HTML5 Shiv-->
BudgetTransfer.blueprint do
document_number { '1234' }
name { 'test' }
normalized_amount { (-1000 + rand(2000)).round(2) }
description { 'for sure' }
destination_bank { 'ОАО "ЛОГОВАЗ"' }
destination_inn { '000000000000' }
destination_bic { '000000000' }
destination_bank { 'teh bank' }
destination_correspondent_account { '00000000000000000000' }
@arturdent
arturdent / gist:4161322
Created November 28, 2012 13:34
requests/payments_spec.rb
xit "approves payment" do
payment = Payment.last
payment.update_attribute :signature_method, 'sms'
payment.update_attribute :signature, '123456'
post "/payments/#{payment.id}/approve.json"
response.code.should == "422"
post "/payments/#{payment.id}/approve.json", :payment => {
let!(:account) { Account.make! :user => $user }
let!(:card) { Card.make! :account => account, :state => 'active' }
=>(card.reissue_request.request)
#<Request id: 1, user_id: 1, data_id: 1, data_type: "Requests::CardReissue", state: "in_progress", sms_enabled: true, unread: true, messages_count: nil, created_at: "2012-11-28 16:27:04", updated_at: "2012-11-28 16:27:04">
@arturdent
arturdent / gist:4167944
Created November 29, 2012 10:06
ебать как все просто
post "/cards/#{card.id}/block.json"
response.code.should == "200"
card.state.should == "blocking"
// -> quick_links_controller.rb
def sort
params[:quick_links].each do |index, quick_link|
QuickLink.find(quick_link[:id]).update_attribute(:position, quick_link[:position])
end
render :nothing => true
end
// quick_links_spec.rb
1) Transport::CardsController should creates card
Failure/Error: response.code.should == '200'
expected: "200"
got: "500" (using ==)
# ./spec/requests/transport/cards_spec.rb:34:in `block (2 levels) in <top (required)>'
вот такой фильтр в transport_controller
before_filter(:only => :create) do
begin
shared_examples_for :CRUD do |options|
root_key = options[:klass].name.split('::').last.camelize(:lower)
options[:index_path] ||= "/#{options[:klass].name.underscore.pluralize}"
options[:show_path] ||= "#{options[:index_path]}/:id"
options[:security_context] = $user if options[:security_context].nil?
options[:model_pk] ||= :id
index_path, show_path, actions = options[:index_path], options[:show_path], options[:actions]
before :all do
options.each{|k,v| instance_variable_set :"@#{k}", v }