smartkiosk-server 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +32 -0
- data/.rspec +1 -0
- data/Capfile +4 -0
- data/Gemfile +71 -0
- data/Gemfile.lock +439 -0
- data/Guardfile +25 -0
- data/LICENSE +287 -0
- data/README.md +13 -0
- data/Rakefile +5 -0
- data/app/acquirers/cards_mkb_acquirer.rb +87 -0
- data/app/acquirers/cash_acquirer.rb +22 -0
- data/app/admin/agents.rb +108 -0
- data/app/admin/collections.rb +62 -0
- data/app/admin/commissions.rb +87 -0
- data/app/admin/gateways.rb +183 -0
- data/app/admin/limits.rb +82 -0
- data/app/admin/payments.rb +246 -0
- data/app/admin/provider_groups.rb +60 -0
- data/app/admin/provider_profiles.rb +11 -0
- data/app/admin/provider_receipt_templates.rb +82 -0
- data/app/admin/providers.rb +201 -0
- data/app/admin/rebates.rb +83 -0
- data/app/admin/report_results.rb +66 -0
- data/app/admin/report_templates.rb +209 -0
- data/app/admin/reports.rb +158 -0
- data/app/admin/revisions.rb +120 -0
- data/app/admin/system_receipt_templates.rb +76 -0
- data/app/admin/terminal_builds.rb +39 -0
- data/app/admin/terminal_profiles.rb +123 -0
- data/app/admin/terminals.rb +388 -0
- data/app/admin/users.rb +117 -0
- data/app/admin/versions.rb +131 -0
- data/app/admin/welcome.rb +64 -0
- data/app/assets/fonts/PT_Sans-Web-Bold.eot +0 -0
- data/app/assets/fonts/PT_Sans-Web-Bold.svg +6386 -0
- data/app/assets/fonts/PT_Sans-Web-Bold.ttf +0 -0
- data/app/assets/fonts/PT_Sans-Web-Bold.woff +0 -0
- data/app/assets/fonts/PT_Sans-Web-Regular.eot +0 -0
- data/app/assets/fonts/PT_Sans-Web-Regular.svg +5650 -0
- data/app/assets/fonts/PT_Sans-Web-Regular.ttf +0 -0
- data/app/assets/fonts/PT_Sans-Web-Regular.woff +0 -0
- data/app/assets/images/chosen-sprite.png +0 -0
- data/app/assets/javascripts/active_admin/chosen.js.erb.coffee +12 -0
- data/app/assets/javascripts/active_admin/qtip.js.coffee +22 -0
- data/app/assets/javascripts/active_admin/sortable_forms.js.coffee +14 -0
- data/app/assets/javascripts/active_admin.js.coffee +9 -0
- data/app/assets/javascripts/application.js +15 -0
- data/app/assets/javascripts/report_templates.js.coffee +10 -0
- data/app/assets/javascripts/terminals.js.coffee +12 -0
- data/app/assets/stylesheets/active_admin/PIE.css.scss +18 -0
- data/app/assets/stylesheets/active_admin/filter_numeric_range.css.scss +14 -0
- data/app/assets/stylesheets/active_admin/selectable_check_boxes.css.scss +12 -0
- data/app/assets/stylesheets/active_admin/sortable_forms.css.scss +11 -0
- data/app/assets/stylesheets/active_admin.css.scss +705 -0
- data/app/assets/stylesheets/fonts.css.scss +14 -0
- data/app/assets/stylesheets/provider_groups.css.scss +12 -0
- data/app/assets/stylesheets/provider_receipt_templates.css.scss +12 -0
- data/app/assets/stylesheets/terminals.css.scss +9 -0
- data/app/controllers/application_controller.rb +12 -0
- data/app/controllers/collections_controller.rb +10 -0
- data/app/controllers/payments_controller.rb +73 -0
- data/app/controllers/system_receipt_templates_controller.rb +10 -0
- data/app/controllers/terminal_builds_controller.rb +5 -0
- data/app/controllers/terminal_orders_controller.rb +25 -0
- data/app/controllers/terminal_pings_controller.rb +45 -0
- data/app/controllers/welcome_controller.rb +5 -0
- data/app/helpers/active_admin/report_templates_helper.rb +56 -0
- data/app/helpers/active_admin/views_helper.rb +20 -0
- data/app/helpers/application_helper.rb +2 -0
- data/app/mailers/.gitkeep +0 -0
- data/app/models/.gitkeep +0 -0
- data/app/models/ability.rb +30 -0
- data/app/models/agent.rb +24 -0
- data/app/models/collection.rb +65 -0
- data/app/models/commission.rb +77 -0
- data/app/models/commission_section.rb +75 -0
- data/app/models/gateway.rb +99 -0
- data/app/models/gateway_attachment.rb +9 -0
- data/app/models/gateway_setting.rb +7 -0
- data/app/models/gateway_switch.rb +7 -0
- data/app/models/limit.rb +77 -0
- data/app/models/limit_section.rb +58 -0
- data/app/models/payment.rb +322 -0
- data/app/models/provider.rb +59 -0
- data/app/models/provider_field.rb +7 -0
- data/app/models/provider_gateway.rb +47 -0
- data/app/models/provider_group.rb +45 -0
- data/app/models/provider_profile.rb +9 -0
- data/app/models/provider_rebate.rb +69 -0
- data/app/models/provider_receipt_template.rb +85 -0
- data/app/models/rebate.rb +84 -0
- data/app/models/report.rb +71 -0
- data/app/models/report_result.rb +11 -0
- data/app/models/report_template.rb +56 -0
- data/app/models/revision.rb +104 -0
- data/app/models/role.rb +48 -0
- data/app/models/system_receipt_template.rb +13 -0
- data/app/models/terminal.rb +126 -0
- data/app/models/terminal_build.rb +62 -0
- data/app/models/terminal_order.rb +42 -0
- data/app/models/terminal_ping.rb +120 -0
- data/app/models/terminal_profile.rb +51 -0
- data/app/models/terminal_profile_promotion.rb +18 -0
- data/app/models/terminal_profile_provider.rb +11 -0
- data/app/models/terminal_profile_provider_group.rb +19 -0
- data/app/models/user.rb +38 -0
- data/app/models/user_role.rb +45 -0
- data/app/reports/agents_report.rb +81 -0
- data/app/reports/collections_report.rb +151 -0
- data/app/reports/payments_report.rb +189 -0
- data/app/reports/terminals_report.rb +123 -0
- data/app/uploaders/file_uploader.rb +53 -0
- data/app/uploaders/icon_uploader.rb +15 -0
- data/app/uploaders/zip_uploader.rb +53 -0
- data/app/views/admin/gateways/providers.html.arb +10 -0
- data/app/views/admin/revisions/payments.html.arb +28 -0
- data/app/views/admin/terminal_profiles/_tree.html.haml +35 -0
- data/app/views/admin/terminal_profiles/sort.html.haml +21 -0
- data/app/views/admin/terminals/pings.html.arb +55 -0
- data/app/views/admin/terminals/upgrade_build.html.arb +30 -0
- data/app/views/layouts/application.html.erb +1 -0
- data/app/views/welcome/index.html.erb +25 -0
- data/app/workers/pay_worker.rb +11 -0
- data/app/workers/report_worker.rb +7 -0
- data/app/workers/revise_worker.rb +7 -0
- data/config/acquiring.yml +13 -0
- data/config/application.rb +75 -0
- data/config/boot.rb +6 -0
- data/config/database.yml +17 -0
- data/config/deploy/roundlake-passenger.rb +3 -0
- data/config/deploy/roundlake-trinidad.rb +3 -0
- data/config/deploy.rb +37 -0
- data/config/environment.rb +5 -0
- data/config/environments/development.rb +39 -0
- data/config/environments/production.rb +67 -0
- data/config/environments/test.rb +37 -0
- data/config/initializers/active_admin.rb +31 -0
- data/config/initializers/backtrace_silencers.rb +7 -0
- data/config/initializers/devise.rb +232 -0
- data/config/initializers/inflections.rb +15 -0
- data/config/initializers/mime_types.rb +5 -0
- data/config/initializers/money.rb +6 -0
- data/config/initializers/redis.rb +4 -0
- data/config/initializers/secret_token.rb +7 -0
- data/config/initializers/session_store.rb +8 -0
- data/config/initializers/setup_rack.rb +1 -0
- data/config/initializers/wrap_parameters.rb +14 -0
- data/config/locales/active_admin.ru.yml +71 -0
- data/config/locales/activerecord.ru.yml +645 -0
- data/config/locales/devise.ru.yml +57 -0
- data/config/locales/ru.yml +33 -0
- data/config/locales/smartkiosk.gateways.ru.yml +241 -0
- data/config/locales/smartkiosk.hardware.ru.yml +38 -0
- data/config/locales/smartkiosk.reports.ru.yml +56 -0
- data/config/locales/smartkiosk.ru.yml +163 -0
- data/config/nginx.conf +9 -0
- data/config/redis.yml +9 -0
- data/config/routes.rb +48 -0
- data/config/schedule.rb +13 -0
- data/config/sidekiq.yml +5 -0
- data/config/trinidad.yml +6 -0
- data/config.ru +4 -0
- data/db/migrate/20120825083035_create_terminals.rb +47 -0
- data/db/migrate/20120825083305_create_payments.rb +51 -0
- data/db/migrate/20120827062618_devise_create_users.rb +50 -0
- data/db/migrate/20120827132621_create_admin_notes.rb +17 -0
- data/db/migrate/20120827132622_move_admin_notes_to_comments.rb +25 -0
- data/db/migrate/20120903193346_create_providers.rb +24 -0
- data/db/migrate/20120922075345_create_collections.rb +26 -0
- data/db/migrate/20120922080440_create_agents.rb +29 -0
- data/db/migrate/20120922081104_create_commissions.rb +10 -0
- data/db/migrate/20120927035841_create_gateways.rb +13 -0
- data/db/migrate/20120927040626_create_provider_gateways.rb +13 -0
- data/db/migrate/20120927091849_create_limits.rb +10 -0
- data/db/migrate/20120927164647_create_roles.rb +14 -0
- data/db/migrate/20121003131522_create_report_templates.rb +18 -0
- data/db/migrate/20121007135652_create_reports.rb +13 -0
- data/db/migrate/20121008073905_create_report_results.rb +10 -0
- data/db/migrate/20121017114538_create_gateway_settings.rb +12 -0
- data/db/migrate/20121017114556_create_gateway_attachments.rb +10 -0
- data/db/migrate/20121019132606_create_revisions.rb +19 -0
- data/db/migrate/20121023073501_create_gateway_switches.rb +10 -0
- data/db/migrate/20121112142743_create_terminal_orders.rb +13 -0
- data/db/migrate/20121118191553_create_versions.rb +19 -0
- data/db/migrate/20121125093414_create_system_receipt_templates.rb +9 -0
- data/db/migrate/20121127192257_create_terminal_builds.rb +10 -0
- data/db/migrate/20121212053441_create_rebates.rb +15 -0
- data/db/migrate/20121216143855_create_provider_receipt_templates.rb +9 -0
- data/db/migrate/20130101091100_create_terminal_profiles.rb +13 -0
- data/db/migrate/20130101091734_create_provider_rebates.rb +21 -0
- data/db/migrate/20130102164447_create_limit_sections.rb +14 -0
- data/db/migrate/20130102164503_create_commission_sections.rb +17 -0
- data/db/migrate/20130102171743_create_provider_profiles.rb +10 -0
- data/db/migrate/20130103152507_create_provider_fields.rb +17 -0
- data/db/migrate/20130103154526_create_provider_groups.rb +10 -0
- data/db/migrate/20130104063628_create_terminal_profile_providers.rb +11 -0
- data/db/migrate/20130104090957_create_terminal_profile_provider_groups.rb +11 -0
- data/db/migrate/20130108091644_create_terminal_profile_promotions.rb +10 -0
- data/db/schema.rb +489 -0
- data/db/seeds/receipt_templates/payment.txt +19 -0
- data/db/seeds/receipt_templates/system/balance.txt +13 -0
- data/db/seeds/receipt_templates/system/collection.txt +17 -0
- data/db/seeds/receipt_templates/system/touchtest.txt +15 -0
- data/db/seeds.rb +18 -0
- data/doc/README_FOR_APP +2 -0
- data/init.rb +1 -0
- data/lib/active_admin/cancan_integration.rb +81 -0
- data/lib/active_admin/form_builder_fix.rb +76 -0
- data/lib/active_admin/inputs/filter_date_range_input_fix.rb +24 -0
- data/lib/active_admin/inputs/filter_multiple_select_input.rb +18 -0
- data/lib/active_admin/inputs/filter_numeric_range_input.rb +31 -0
- data/lib/active_admin/resource_controller_fix.rb +23 -0
- data/lib/active_admin/views/pages/base_fix.rb +13 -0
- data/lib/assets/.gitkeep +0 -0
- data/lib/blueprints.rb +79 -0
- data/lib/date_expander.rb +38 -0
- data/lib/dav4rack/build_resource.rb +59 -0
- data/lib/formtastic/inputs/selectable_check_boxes.rb +39 -0
- data/lib/paper_trail/version_fix.rb +3 -0
- data/lib/report_builder.rb +88 -0
- data/lib/seeder.rb +103 -0
- data/lib/smartkiosk/server/version.rb +5 -0
- data/lib/smartkiosk/server.rb +35 -0
- data/lib/string_file.rb +12 -0
- data/lib/tasks/.gitkeep +0 -0
- data/lib/tasks/db.rake +27 -0
- data/lib/tasks/dump.rake +53 -0
- data/lib/tasks/matrioshka.rake +16 -0
- data/log/.gitkeep +0 -0
- data/log/gateways/.gitkeep +0 -0
- data/public/404.html +26 -0
- data/public/422.html +26 -0
- data/public/500.html +25 -0
- data/public/robots.txt +5 -0
- data/script/rails +6 -0
- data/smartkiosk-server.gemspec +23 -0
- data/spec/controllers/collections_controller_spec.rb +32 -0
- data/spec/controllers/payments_controller_spec.rb +123 -0
- data/spec/controllers/system_receipt_templates_controller_spec.rb +5 -0
- data/spec/controllers/terminal_builds_controller_spec.rb +5 -0
- data/spec/controllers/terminal_orders_controller_spec.rb +32 -0
- data/spec/controllers/terminal_pings_controller_spec.rb +31 -0
- data/spec/spec_helper.rb +66 -0
- data/vendor/assets/javascripts/.gitkeep +0 -0
- data/vendor/assets/javascripts/chosen.jquery.js +1026 -0
- data/vendor/assets/javascripts/datepicker-ru.jquery.js +21 -0
- data/vendor/assets/javascripts/nestedSortable.jquery.js +429 -0
- data/vendor/assets/javascripts/qtip.jquery.js +3403 -0
- data/vendor/assets/stylesheets/.gitkeep +0 -0
- data/vendor/assets/stylesheets/chosen.jquery.css +397 -0
- data/vendor/assets/stylesheets/modules/PIE.htc +96 -0
- data/vendor/assets/stylesheets/qtip.jquery.css.scss +604 -0
- data/vendor/plugins/.gitkeep +0 -0
- metadata +333 -0
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'rails/engine'
|
2
|
+
|
3
|
+
require_relative 'server/version'
|
4
|
+
|
5
|
+
module Smartkiosk
|
6
|
+
module Server
|
7
|
+
|
8
|
+
def self.revision
|
9
|
+
file = File.expand_path '../../../REVISION'
|
10
|
+
File.exist?(file) ? File.read(file).strip : nil
|
11
|
+
end
|
12
|
+
|
13
|
+
class Engine < ::Rails::Engine
|
14
|
+
initializer 'matrioshka', :before => :set_autoload_paths do |app|
|
15
|
+
|
16
|
+
# Rails
|
17
|
+
app.class.configure do
|
18
|
+
config.i18n.load_path += Dir[Smartkiosk::Server::Engine.root.join(*%w(config locales *.{rb,yml})).to_s]
|
19
|
+
config.autoload_paths += %W(#{Smartkiosk::Server::Engine.root.join 'lib'})
|
20
|
+
config.paths['db/migrate'] += Smartkiosk::Server::Engine.paths['db/migrate'].existent
|
21
|
+
end
|
22
|
+
|
23
|
+
# ActiveAdmin
|
24
|
+
ActiveAdmin.setup do |config|
|
25
|
+
config.load_paths << Smartkiosk::Server::Engine.root.join('app/admin')
|
26
|
+
end
|
27
|
+
|
28
|
+
# TODO: Remove this as soon as AA fixed
|
29
|
+
config.after_initialize do
|
30
|
+
I18n.reload!
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/string_file.rb
ADDED
data/lib/tasks/.gitkeep
ADDED
File without changes
|
data/lib/tasks/db.rake
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
namespace :db do
|
2
|
+
desc 'Remove and install new database from scratch'
|
3
|
+
task :install => [:drop_redis, :drop_tables, :'db:migrate', :'db:seed'] do
|
4
|
+
end
|
5
|
+
|
6
|
+
task :drop_redis => :environment do
|
7
|
+
puts "Clearing Redis"
|
8
|
+
Redis.current.flushdb
|
9
|
+
end
|
10
|
+
|
11
|
+
task :drop_tables => :environment do
|
12
|
+
puts "Droping all tables..."
|
13
|
+
puts "-"*10
|
14
|
+
|
15
|
+
ActiveRecord::Base.connection.drop_table "schema_migrations"
|
16
|
+
|
17
|
+
root = File.expand_path('../../../app/models/', __FILE__)
|
18
|
+
models = Dir["#{root}/**"].each{|x| require x; }
|
19
|
+
tables = ActiveRecord::Base.connection.tables
|
20
|
+
|
21
|
+
ActiveRecord::Base.subclasses.map{|x| x.table_name}.each do |x|
|
22
|
+
ActiveRecord::Base.connection.drop_table x if tables.include? x
|
23
|
+
puts "#{x} droped;"
|
24
|
+
end
|
25
|
+
puts "-"*10
|
26
|
+
end
|
27
|
+
end
|
data/lib/tasks/dump.rake
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
namespace :dump do
|
4
|
+
task :providers => :environment do
|
5
|
+
FileUtils.mkdir_p root = Rails.root.join('tmp', 'dump')
|
6
|
+
FileUtils.mkdir_p root.join('icons', 'providers')
|
7
|
+
FileUtils.mkdir_p root.join('icons', 'provider_groups')
|
8
|
+
|
9
|
+
providers = Provider.all
|
10
|
+
provider_groups = ProviderGroup.all
|
11
|
+
|
12
|
+
data = {
|
13
|
+
:providers => providers.map{|x|
|
14
|
+
{
|
15
|
+
:id => x.id,
|
16
|
+
:title => x.title,
|
17
|
+
:keyword => x.keyword,
|
18
|
+
:fields => x.fields_dump,
|
19
|
+
:group_id => x.provider_group_id
|
20
|
+
}
|
21
|
+
},
|
22
|
+
:provider_groups => provider_groups.map{|x|
|
23
|
+
{
|
24
|
+
:id => x.id,
|
25
|
+
:title => x.title,
|
26
|
+
:parent_id => x.provider_group_id
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
File.open(root.join('data.yml'), 'w') do |f|
|
32
|
+
YAML.dump data, f
|
33
|
+
end
|
34
|
+
|
35
|
+
providers.each do |p|
|
36
|
+
next if p.icon.blank?
|
37
|
+
|
38
|
+
path = p.icon.path
|
39
|
+
type = p.icon.path.split('.').last
|
40
|
+
|
41
|
+
FileUtils.cp path, root.join('icons', 'providers', "#{p.keyword}.#{type}")
|
42
|
+
end
|
43
|
+
|
44
|
+
provider_groups.each do |pg|
|
45
|
+
next if pg.icon.blank?
|
46
|
+
|
47
|
+
path = pg.icon.path
|
48
|
+
type = pg.icon.path.split('.').last
|
49
|
+
|
50
|
+
FileUtils.cp path, root.join('icons', 'provider_groups', "#{pg.keyword}.#{type}")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'matrioshka'
|
2
|
+
|
3
|
+
namespace 'smartkiosk_server' do
|
4
|
+
task :link do
|
5
|
+
generator = Matrioshka::Generator.new
|
6
|
+
location = File.expand_path File.join(*['..']*3), __FILE__
|
7
|
+
|
8
|
+
if location == Rails.root.to_s
|
9
|
+
puts "This task was successfully registered. Call it from the gem consumer not from the gem itself."
|
10
|
+
else
|
11
|
+
generator.copy_gemfile_from location, 'Smartkiosk::Server'
|
12
|
+
generator.prepend_seeds 'Smartkiosk::Server'
|
13
|
+
generator.run "bundle install"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/log/.gitkeep
ADDED
File without changes
|
File without changes
|
data/public/404.html
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/404.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
23
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
data/public/422.html
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/422.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
data/public/500.html
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/500.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
23
|
+
</div>
|
24
|
+
</body>
|
25
|
+
</html>
|
data/public/robots.txt
ADDED
data/script/rails
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
@@ -0,0 +1,23 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'smartkiosk/server/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = 'smartkiosk-server'
|
7
|
+
gem.version = Smartkiosk::Server::VERSION
|
8
|
+
gem.authors = ['Boris Staal']
|
9
|
+
gem.email = ['boris@roundlake.ru']
|
10
|
+
gem.description = %q{Smartkiosk server application}
|
11
|
+
gem.summary = gem.description
|
12
|
+
gem.homepage = 'https://github.com/smartkiosk/smartkiosk-server'
|
13
|
+
gem.files = `git ls-files`.split($/)
|
14
|
+
|
15
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
16
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
|
+
gem.require_paths = ['lib']
|
18
|
+
|
19
|
+
gem.add_dependency 'rails', '= 3.2.11'
|
20
|
+
gem.add_dependency 'matrioshka', '>= 0.1.1'
|
21
|
+
|
22
|
+
gem.post_install_message = "Please run `rake smartkiosk_server:link` to finish the installation."
|
23
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CollectionsController do
|
4
|
+
render_views
|
5
|
+
|
6
|
+
before(:all) do
|
7
|
+
@agent = Agent.create!(:title => 'test')
|
8
|
+
@terminal = Terminal.make!(:keyword => 'test', :agent => @agent)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "creates" do
|
12
|
+
post :create, :terminal => 'foobar'
|
13
|
+
response.status.should == 404
|
14
|
+
|
15
|
+
post :create, :terminal => 'test'
|
16
|
+
response.status.should == 400
|
17
|
+
|
18
|
+
post :create, :terminal => 'test', :collection => {
|
19
|
+
:session_ids => ['111', '222'],
|
20
|
+
:collected_at => DateTime.now,
|
21
|
+
:banknotes => {
|
22
|
+
'10' => 14,
|
23
|
+
'1000' => 1
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
response.status.should == 200
|
28
|
+
collection = @terminal.collections.first
|
29
|
+
response.body.should == @terminal.collections.first.id.to_s
|
30
|
+
collection.banknotes.should == {'10' => '14', '1000' => '1'}
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe PaymentsController do
|
4
|
+
render_views
|
5
|
+
|
6
|
+
before(:all) do
|
7
|
+
@profile = ProviderProfile.make!
|
8
|
+
@agent = Agent.create!(:title => 'test')
|
9
|
+
@terminal = Terminal.make!(:keyword => 'test', :agent => @agent)
|
10
|
+
@provider = Provider.make!(:provider_profile => @profile, :title => 'test', :keyword => 'test')
|
11
|
+
@gateway = Gateway.create!(:title => 'test', :keyword => 'dummy', :payzilla => 'dummy')
|
12
|
+
|
13
|
+
ProviderGateway.create!(:provider => @provider, :gateway => @gateway, :priority => 1)
|
14
|
+
|
15
|
+
ProviderReceiptTemplate.create!(
|
16
|
+
:system => true,
|
17
|
+
:template => "{{ payment_enrolled_amount }}"
|
18
|
+
)
|
19
|
+
|
20
|
+
@commission = Commission.create! :provider_profile => @profile,
|
21
|
+
:start => '1000-1-1', :finish => '9999-1-1'
|
22
|
+
|
23
|
+
@limit = Limit.create! :provider_profile => @profile,
|
24
|
+
:start => '1000-1-1', :finish => '9999-1-1'
|
25
|
+
|
26
|
+
CommissionSection.create! :commission => @commission, :min => 0, :max => 9999
|
27
|
+
LimitSection.create! :limit => @limit, :min => 0, :max => 9999
|
28
|
+
end
|
29
|
+
|
30
|
+
it "creates" do
|
31
|
+
post :create,
|
32
|
+
:terminal => 'test',
|
33
|
+
:provider => 'test',
|
34
|
+
:payment => {
|
35
|
+
:session_id => 31337,
|
36
|
+
:account => '9261111111',
|
37
|
+
:payment_type => Payment::TYPE_CASH
|
38
|
+
}
|
39
|
+
|
40
|
+
result = ActiveSupport::JSON.decode(response.body)
|
41
|
+
result.should == {
|
42
|
+
"id" => 1,
|
43
|
+
"state" => "checked",
|
44
|
+
"requires_print" => true,
|
45
|
+
"limits" => [{"max"=>"9999.0", "min"=>"0.0", "weight"=>1}],
|
46
|
+
"commissions" => [{"max"=>"9999.0", "min"=>"0.0", "payment_type"=>nil, "percent_fee"=>"0.0", "static_fee"=>"0.0", "weight"=>1}],
|
47
|
+
"receipt_template" => "{{ payment_enrolled_amount }}"
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
it "pays" do
|
52
|
+
post :create,
|
53
|
+
:terminal => 'test',
|
54
|
+
:provider => 'test',
|
55
|
+
:payment => {
|
56
|
+
:session_id => 31337,
|
57
|
+
:account => '9261111111',
|
58
|
+
:payment_type => Payment::TYPE_CASH
|
59
|
+
}
|
60
|
+
|
61
|
+
result = ActiveSupport::JSON.decode(response.body)
|
62
|
+
result.should == {
|
63
|
+
"id" => 1,
|
64
|
+
"state" => "checked",
|
65
|
+
"requires_print" => true,
|
66
|
+
"limits" => [{"max"=>"9999.0", "min"=>"0.0", "weight"=>1}],
|
67
|
+
"commissions" => [{"max"=>"9999.0", "min"=>"0.0", "payment_type"=>nil, "percent_fee"=>"0.0", "static_fee"=>"0.0", "weight"=>1}],
|
68
|
+
"receipt_template" => "{{ payment_enrolled_amount }}"
|
69
|
+
}
|
70
|
+
|
71
|
+
post :pay,
|
72
|
+
:terminal => 'test',
|
73
|
+
:id => 1,
|
74
|
+
:payment => {
|
75
|
+
:paid_amount => 100
|
76
|
+
}
|
77
|
+
response.status.should == 200
|
78
|
+
|
79
|
+
PayWorker.new.perform 1
|
80
|
+
payment = Payment.find 1
|
81
|
+
payment.state.should == "paid"
|
82
|
+
end
|
83
|
+
|
84
|
+
xit "pays with card" do
|
85
|
+
post :create,
|
86
|
+
:terminal => 'test',
|
87
|
+
:provider => 'test',
|
88
|
+
:payment => {
|
89
|
+
:session_id => 31337,
|
90
|
+
:account => '9261111111',
|
91
|
+
:payment_type => Payment::TYPE_INNER_CARD
|
92
|
+
}
|
93
|
+
|
94
|
+
result = ActiveSupport::JSON.decode(response.body)
|
95
|
+
result.should == {
|
96
|
+
"id" => 1,
|
97
|
+
"state" => "checked",
|
98
|
+
"requires_print" => true,
|
99
|
+
"limits" => [{"max"=>"9999.0", "min"=>"0.0", "weight"=>1}],
|
100
|
+
"commissions" => [{"max"=>"9999.0", "min"=>"0.0", "payment_type"=>nil, "percent_fee"=>"0.0", "static_fee"=>"0.0", "weight"=>1}],
|
101
|
+
"receipt_template" => "{{ payment_enrolled_amount }}"
|
102
|
+
}
|
103
|
+
post :pay,
|
104
|
+
:terminal => 'test',
|
105
|
+
:id => 1,
|
106
|
+
:payment => {
|
107
|
+
:card_track1 => "B4432710006099018^CARD2/TEST ^1412121170030000000000693000000",
|
108
|
+
:card_track2 => "4432710006099018=141212117003693",
|
109
|
+
:paid_amount => 100
|
110
|
+
}
|
111
|
+
response.status.should == 200
|
112
|
+
|
113
|
+
begin
|
114
|
+
PayWorker.new.perform 1
|
115
|
+
|
116
|
+
payment = Payment.find 1
|
117
|
+
|
118
|
+
payment.state.should == "paid"
|
119
|
+
ensure
|
120
|
+
CardsMkbAcquirer.stop
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe TerminalOrdersController do
|
4
|
+
before(:all) do
|
5
|
+
@agent = Agent.create!(:title => 'test')
|
6
|
+
@terminal = Terminal.make!(:keyword => 'test', :agent => @agent)
|
7
|
+
|
8
|
+
@terminal.order! :enable
|
9
|
+
|
10
|
+
@order = @terminal.terminal_orders.first
|
11
|
+
@spy = Terminal.make!(:keyword => 'test2', :agent => @agent)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "acknowledges" do
|
15
|
+
post :acknowledge, :terminal => @spy.keyword, :id => @order.id
|
16
|
+
response.status.should == 404
|
17
|
+
|
18
|
+
post :acknowledge, :terminal => @terminal.keyword, :id => @order.id, :error => 'test'
|
19
|
+
response.status.should == 200
|
20
|
+
@order.reload.sent?.should == true
|
21
|
+
@order.error?.should == true
|
22
|
+
end
|
23
|
+
|
24
|
+
it "completes" do
|
25
|
+
post :complete, :terminal => @spy.keyword, :id => @order.id
|
26
|
+
response.status.should == 404
|
27
|
+
|
28
|
+
post :complete, :terminal => @terminal.keyword, :id => @order.id
|
29
|
+
response.status.should == 200
|
30
|
+
@order.reload.complete?.should == true
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe TerminalPingsController do
|
4
|
+
before(:all) do
|
5
|
+
@agent = Agent.create!(:title => 'test')
|
6
|
+
@terminal = Terminal.make!(:keyword => 'test', :agent => @agent)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "creates" do
|
10
|
+
post :create, :terminal => 'foobar'
|
11
|
+
response.status.should == 404
|
12
|
+
|
13
|
+
post :create, :terminal => 'test', :terminal_ping => {
|
14
|
+
:banknotes => {
|
15
|
+
'10' => '14',
|
16
|
+
'1000' => '1'
|
17
|
+
},
|
18
|
+
:ip => '127.0.0.1',
|
19
|
+
:cash_acceptor => {
|
20
|
+
'error' => '-1'
|
21
|
+
},
|
22
|
+
:providers => {
|
23
|
+
:updated_at => DateTime.now,
|
24
|
+
:ids => [1, 2, 3]
|
25
|
+
}
|
26
|
+
}
|
27
|
+
@terminal.pings.count.should == 1
|
28
|
+
@terminal.pings.first.cash_sum.should == 1140
|
29
|
+
@terminal.pings.first.ip.should == '127.0.0.1'
|
30
|
+
end
|
31
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
ENV["RAILS_ENV"] = 'test'
|
2
|
+
|
3
|
+
require 'spork'
|
4
|
+
#uncomment the following line to use spork with the debugger
|
5
|
+
#require 'spork/ext/ruby-debug'
|
6
|
+
|
7
|
+
Spork.prefork do
|
8
|
+
require File.expand_path("../../config/environment", __FILE__)
|
9
|
+
require 'rspec/rails'
|
10
|
+
require 'rspec/autorun'
|
11
|
+
require 'sidekiq/testing'
|
12
|
+
|
13
|
+
load "#{Rails.root}/db/schema.rb"
|
14
|
+
end
|
15
|
+
|
16
|
+
Spork.each_run do
|
17
|
+
require 'blueprints'
|
18
|
+
|
19
|
+
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| load f}
|
20
|
+
Dir[Rails.root.join("app/models/**/*.rb")].each {|m| load m}
|
21
|
+
|
22
|
+
RSpec.configure do |config|
|
23
|
+
config.before(:suite) do
|
24
|
+
DatabaseCleaner.strategy = :truncation
|
25
|
+
DatabaseCleaner.clean_with(:truncation)
|
26
|
+
|
27
|
+
Redis.current.flushdb
|
28
|
+
end
|
29
|
+
|
30
|
+
config.before(:all) do
|
31
|
+
DatabaseCleaner.start
|
32
|
+
end
|
33
|
+
|
34
|
+
config.after(:all) do
|
35
|
+
DatabaseCleaner.clean
|
36
|
+
Redis.current.flushdb
|
37
|
+
end
|
38
|
+
|
39
|
+
# ## Mock Framework
|
40
|
+
#
|
41
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
42
|
+
#
|
43
|
+
# config.mock_with :mocha
|
44
|
+
# config.mock_with :flexmock
|
45
|
+
# config.mock_with :rr
|
46
|
+
|
47
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
48
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
49
|
+
|
50
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
51
|
+
# examples within a transaction, remove the following line or assign false
|
52
|
+
# instead of true.
|
53
|
+
config.use_transactional_fixtures = true
|
54
|
+
|
55
|
+
# If true, the base class of anonymous controllers will be inferred
|
56
|
+
# automatically. This will be the default behavior in future versions of
|
57
|
+
# rspec-rails.
|
58
|
+
config.infer_base_class_for_anonymous_controllers = false
|
59
|
+
|
60
|
+
# Run specs in random order to surface order dependencies. If you find an
|
61
|
+
# order dependency and want to debug it, you can fix the order by providing
|
62
|
+
# the seed, which is printed after each run.
|
63
|
+
# --seed 1234
|
64
|
+
config.order = "random"
|
65
|
+
end
|
66
|
+
end
|
File without changes
|