smartkiosk-server 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (254) hide show
  1. data/.gitignore +32 -0
  2. data/.rspec +1 -0
  3. data/Capfile +4 -0
  4. data/Gemfile +71 -0
  5. data/Gemfile.lock +439 -0
  6. data/Guardfile +25 -0
  7. data/LICENSE +287 -0
  8. data/README.md +13 -0
  9. data/Rakefile +5 -0
  10. data/app/acquirers/cards_mkb_acquirer.rb +87 -0
  11. data/app/acquirers/cash_acquirer.rb +22 -0
  12. data/app/admin/agents.rb +108 -0
  13. data/app/admin/collections.rb +62 -0
  14. data/app/admin/commissions.rb +87 -0
  15. data/app/admin/gateways.rb +183 -0
  16. data/app/admin/limits.rb +82 -0
  17. data/app/admin/payments.rb +246 -0
  18. data/app/admin/provider_groups.rb +60 -0
  19. data/app/admin/provider_profiles.rb +11 -0
  20. data/app/admin/provider_receipt_templates.rb +82 -0
  21. data/app/admin/providers.rb +201 -0
  22. data/app/admin/rebates.rb +83 -0
  23. data/app/admin/report_results.rb +66 -0
  24. data/app/admin/report_templates.rb +209 -0
  25. data/app/admin/reports.rb +158 -0
  26. data/app/admin/revisions.rb +120 -0
  27. data/app/admin/system_receipt_templates.rb +76 -0
  28. data/app/admin/terminal_builds.rb +39 -0
  29. data/app/admin/terminal_profiles.rb +123 -0
  30. data/app/admin/terminals.rb +388 -0
  31. data/app/admin/users.rb +117 -0
  32. data/app/admin/versions.rb +131 -0
  33. data/app/admin/welcome.rb +64 -0
  34. data/app/assets/fonts/PT_Sans-Web-Bold.eot +0 -0
  35. data/app/assets/fonts/PT_Sans-Web-Bold.svg +6386 -0
  36. data/app/assets/fonts/PT_Sans-Web-Bold.ttf +0 -0
  37. data/app/assets/fonts/PT_Sans-Web-Bold.woff +0 -0
  38. data/app/assets/fonts/PT_Sans-Web-Regular.eot +0 -0
  39. data/app/assets/fonts/PT_Sans-Web-Regular.svg +5650 -0
  40. data/app/assets/fonts/PT_Sans-Web-Regular.ttf +0 -0
  41. data/app/assets/fonts/PT_Sans-Web-Regular.woff +0 -0
  42. data/app/assets/images/chosen-sprite.png +0 -0
  43. data/app/assets/javascripts/active_admin/chosen.js.erb.coffee +12 -0
  44. data/app/assets/javascripts/active_admin/qtip.js.coffee +22 -0
  45. data/app/assets/javascripts/active_admin/sortable_forms.js.coffee +14 -0
  46. data/app/assets/javascripts/active_admin.js.coffee +9 -0
  47. data/app/assets/javascripts/application.js +15 -0
  48. data/app/assets/javascripts/report_templates.js.coffee +10 -0
  49. data/app/assets/javascripts/terminals.js.coffee +12 -0
  50. data/app/assets/stylesheets/active_admin/PIE.css.scss +18 -0
  51. data/app/assets/stylesheets/active_admin/filter_numeric_range.css.scss +14 -0
  52. data/app/assets/stylesheets/active_admin/selectable_check_boxes.css.scss +12 -0
  53. data/app/assets/stylesheets/active_admin/sortable_forms.css.scss +11 -0
  54. data/app/assets/stylesheets/active_admin.css.scss +705 -0
  55. data/app/assets/stylesheets/fonts.css.scss +14 -0
  56. data/app/assets/stylesheets/provider_groups.css.scss +12 -0
  57. data/app/assets/stylesheets/provider_receipt_templates.css.scss +12 -0
  58. data/app/assets/stylesheets/terminals.css.scss +9 -0
  59. data/app/controllers/application_controller.rb +12 -0
  60. data/app/controllers/collections_controller.rb +10 -0
  61. data/app/controllers/payments_controller.rb +73 -0
  62. data/app/controllers/system_receipt_templates_controller.rb +10 -0
  63. data/app/controllers/terminal_builds_controller.rb +5 -0
  64. data/app/controllers/terminal_orders_controller.rb +25 -0
  65. data/app/controllers/terminal_pings_controller.rb +45 -0
  66. data/app/controllers/welcome_controller.rb +5 -0
  67. data/app/helpers/active_admin/report_templates_helper.rb +56 -0
  68. data/app/helpers/active_admin/views_helper.rb +20 -0
  69. data/app/helpers/application_helper.rb +2 -0
  70. data/app/mailers/.gitkeep +0 -0
  71. data/app/models/.gitkeep +0 -0
  72. data/app/models/ability.rb +30 -0
  73. data/app/models/agent.rb +24 -0
  74. data/app/models/collection.rb +65 -0
  75. data/app/models/commission.rb +77 -0
  76. data/app/models/commission_section.rb +75 -0
  77. data/app/models/gateway.rb +99 -0
  78. data/app/models/gateway_attachment.rb +9 -0
  79. data/app/models/gateway_setting.rb +7 -0
  80. data/app/models/gateway_switch.rb +7 -0
  81. data/app/models/limit.rb +77 -0
  82. data/app/models/limit_section.rb +58 -0
  83. data/app/models/payment.rb +322 -0
  84. data/app/models/provider.rb +59 -0
  85. data/app/models/provider_field.rb +7 -0
  86. data/app/models/provider_gateway.rb +47 -0
  87. data/app/models/provider_group.rb +45 -0
  88. data/app/models/provider_profile.rb +9 -0
  89. data/app/models/provider_rebate.rb +69 -0
  90. data/app/models/provider_receipt_template.rb +85 -0
  91. data/app/models/rebate.rb +84 -0
  92. data/app/models/report.rb +71 -0
  93. data/app/models/report_result.rb +11 -0
  94. data/app/models/report_template.rb +56 -0
  95. data/app/models/revision.rb +104 -0
  96. data/app/models/role.rb +48 -0
  97. data/app/models/system_receipt_template.rb +13 -0
  98. data/app/models/terminal.rb +126 -0
  99. data/app/models/terminal_build.rb +62 -0
  100. data/app/models/terminal_order.rb +42 -0
  101. data/app/models/terminal_ping.rb +120 -0
  102. data/app/models/terminal_profile.rb +51 -0
  103. data/app/models/terminal_profile_promotion.rb +18 -0
  104. data/app/models/terminal_profile_provider.rb +11 -0
  105. data/app/models/terminal_profile_provider_group.rb +19 -0
  106. data/app/models/user.rb +38 -0
  107. data/app/models/user_role.rb +45 -0
  108. data/app/reports/agents_report.rb +81 -0
  109. data/app/reports/collections_report.rb +151 -0
  110. data/app/reports/payments_report.rb +189 -0
  111. data/app/reports/terminals_report.rb +123 -0
  112. data/app/uploaders/file_uploader.rb +53 -0
  113. data/app/uploaders/icon_uploader.rb +15 -0
  114. data/app/uploaders/zip_uploader.rb +53 -0
  115. data/app/views/admin/gateways/providers.html.arb +10 -0
  116. data/app/views/admin/revisions/payments.html.arb +28 -0
  117. data/app/views/admin/terminal_profiles/_tree.html.haml +35 -0
  118. data/app/views/admin/terminal_profiles/sort.html.haml +21 -0
  119. data/app/views/admin/terminals/pings.html.arb +55 -0
  120. data/app/views/admin/terminals/upgrade_build.html.arb +30 -0
  121. data/app/views/layouts/application.html.erb +1 -0
  122. data/app/views/welcome/index.html.erb +25 -0
  123. data/app/workers/pay_worker.rb +11 -0
  124. data/app/workers/report_worker.rb +7 -0
  125. data/app/workers/revise_worker.rb +7 -0
  126. data/config/acquiring.yml +13 -0
  127. data/config/application.rb +75 -0
  128. data/config/boot.rb +6 -0
  129. data/config/database.yml +17 -0
  130. data/config/deploy/roundlake-passenger.rb +3 -0
  131. data/config/deploy/roundlake-trinidad.rb +3 -0
  132. data/config/deploy.rb +37 -0
  133. data/config/environment.rb +5 -0
  134. data/config/environments/development.rb +39 -0
  135. data/config/environments/production.rb +67 -0
  136. data/config/environments/test.rb +37 -0
  137. data/config/initializers/active_admin.rb +31 -0
  138. data/config/initializers/backtrace_silencers.rb +7 -0
  139. data/config/initializers/devise.rb +232 -0
  140. data/config/initializers/inflections.rb +15 -0
  141. data/config/initializers/mime_types.rb +5 -0
  142. data/config/initializers/money.rb +6 -0
  143. data/config/initializers/redis.rb +4 -0
  144. data/config/initializers/secret_token.rb +7 -0
  145. data/config/initializers/session_store.rb +8 -0
  146. data/config/initializers/setup_rack.rb +1 -0
  147. data/config/initializers/wrap_parameters.rb +14 -0
  148. data/config/locales/active_admin.ru.yml +71 -0
  149. data/config/locales/activerecord.ru.yml +645 -0
  150. data/config/locales/devise.ru.yml +57 -0
  151. data/config/locales/ru.yml +33 -0
  152. data/config/locales/smartkiosk.gateways.ru.yml +241 -0
  153. data/config/locales/smartkiosk.hardware.ru.yml +38 -0
  154. data/config/locales/smartkiosk.reports.ru.yml +56 -0
  155. data/config/locales/smartkiosk.ru.yml +163 -0
  156. data/config/nginx.conf +9 -0
  157. data/config/redis.yml +9 -0
  158. data/config/routes.rb +48 -0
  159. data/config/schedule.rb +13 -0
  160. data/config/sidekiq.yml +5 -0
  161. data/config/trinidad.yml +6 -0
  162. data/config.ru +4 -0
  163. data/db/migrate/20120825083035_create_terminals.rb +47 -0
  164. data/db/migrate/20120825083305_create_payments.rb +51 -0
  165. data/db/migrate/20120827062618_devise_create_users.rb +50 -0
  166. data/db/migrate/20120827132621_create_admin_notes.rb +17 -0
  167. data/db/migrate/20120827132622_move_admin_notes_to_comments.rb +25 -0
  168. data/db/migrate/20120903193346_create_providers.rb +24 -0
  169. data/db/migrate/20120922075345_create_collections.rb +26 -0
  170. data/db/migrate/20120922080440_create_agents.rb +29 -0
  171. data/db/migrate/20120922081104_create_commissions.rb +10 -0
  172. data/db/migrate/20120927035841_create_gateways.rb +13 -0
  173. data/db/migrate/20120927040626_create_provider_gateways.rb +13 -0
  174. data/db/migrate/20120927091849_create_limits.rb +10 -0
  175. data/db/migrate/20120927164647_create_roles.rb +14 -0
  176. data/db/migrate/20121003131522_create_report_templates.rb +18 -0
  177. data/db/migrate/20121007135652_create_reports.rb +13 -0
  178. data/db/migrate/20121008073905_create_report_results.rb +10 -0
  179. data/db/migrate/20121017114538_create_gateway_settings.rb +12 -0
  180. data/db/migrate/20121017114556_create_gateway_attachments.rb +10 -0
  181. data/db/migrate/20121019132606_create_revisions.rb +19 -0
  182. data/db/migrate/20121023073501_create_gateway_switches.rb +10 -0
  183. data/db/migrate/20121112142743_create_terminal_orders.rb +13 -0
  184. data/db/migrate/20121118191553_create_versions.rb +19 -0
  185. data/db/migrate/20121125093414_create_system_receipt_templates.rb +9 -0
  186. data/db/migrate/20121127192257_create_terminal_builds.rb +10 -0
  187. data/db/migrate/20121212053441_create_rebates.rb +15 -0
  188. data/db/migrate/20121216143855_create_provider_receipt_templates.rb +9 -0
  189. data/db/migrate/20130101091100_create_terminal_profiles.rb +13 -0
  190. data/db/migrate/20130101091734_create_provider_rebates.rb +21 -0
  191. data/db/migrate/20130102164447_create_limit_sections.rb +14 -0
  192. data/db/migrate/20130102164503_create_commission_sections.rb +17 -0
  193. data/db/migrate/20130102171743_create_provider_profiles.rb +10 -0
  194. data/db/migrate/20130103152507_create_provider_fields.rb +17 -0
  195. data/db/migrate/20130103154526_create_provider_groups.rb +10 -0
  196. data/db/migrate/20130104063628_create_terminal_profile_providers.rb +11 -0
  197. data/db/migrate/20130104090957_create_terminal_profile_provider_groups.rb +11 -0
  198. data/db/migrate/20130108091644_create_terminal_profile_promotions.rb +10 -0
  199. data/db/schema.rb +489 -0
  200. data/db/seeds/receipt_templates/payment.txt +19 -0
  201. data/db/seeds/receipt_templates/system/balance.txt +13 -0
  202. data/db/seeds/receipt_templates/system/collection.txt +17 -0
  203. data/db/seeds/receipt_templates/system/touchtest.txt +15 -0
  204. data/db/seeds.rb +18 -0
  205. data/doc/README_FOR_APP +2 -0
  206. data/init.rb +1 -0
  207. data/lib/active_admin/cancan_integration.rb +81 -0
  208. data/lib/active_admin/form_builder_fix.rb +76 -0
  209. data/lib/active_admin/inputs/filter_date_range_input_fix.rb +24 -0
  210. data/lib/active_admin/inputs/filter_multiple_select_input.rb +18 -0
  211. data/lib/active_admin/inputs/filter_numeric_range_input.rb +31 -0
  212. data/lib/active_admin/resource_controller_fix.rb +23 -0
  213. data/lib/active_admin/views/pages/base_fix.rb +13 -0
  214. data/lib/assets/.gitkeep +0 -0
  215. data/lib/blueprints.rb +79 -0
  216. data/lib/date_expander.rb +38 -0
  217. data/lib/dav4rack/build_resource.rb +59 -0
  218. data/lib/formtastic/inputs/selectable_check_boxes.rb +39 -0
  219. data/lib/paper_trail/version_fix.rb +3 -0
  220. data/lib/report_builder.rb +88 -0
  221. data/lib/seeder.rb +103 -0
  222. data/lib/smartkiosk/server/version.rb +5 -0
  223. data/lib/smartkiosk/server.rb +35 -0
  224. data/lib/string_file.rb +12 -0
  225. data/lib/tasks/.gitkeep +0 -0
  226. data/lib/tasks/db.rake +27 -0
  227. data/lib/tasks/dump.rake +53 -0
  228. data/lib/tasks/matrioshka.rake +16 -0
  229. data/log/.gitkeep +0 -0
  230. data/log/gateways/.gitkeep +0 -0
  231. data/public/404.html +26 -0
  232. data/public/422.html +26 -0
  233. data/public/500.html +25 -0
  234. data/public/robots.txt +5 -0
  235. data/script/rails +6 -0
  236. data/smartkiosk-server.gemspec +23 -0
  237. data/spec/controllers/collections_controller_spec.rb +32 -0
  238. data/spec/controllers/payments_controller_spec.rb +123 -0
  239. data/spec/controllers/system_receipt_templates_controller_spec.rb +5 -0
  240. data/spec/controllers/terminal_builds_controller_spec.rb +5 -0
  241. data/spec/controllers/terminal_orders_controller_spec.rb +32 -0
  242. data/spec/controllers/terminal_pings_controller_spec.rb +31 -0
  243. data/spec/spec_helper.rb +66 -0
  244. data/vendor/assets/javascripts/.gitkeep +0 -0
  245. data/vendor/assets/javascripts/chosen.jquery.js +1026 -0
  246. data/vendor/assets/javascripts/datepicker-ru.jquery.js +21 -0
  247. data/vendor/assets/javascripts/nestedSortable.jquery.js +429 -0
  248. data/vendor/assets/javascripts/qtip.jquery.js +3403 -0
  249. data/vendor/assets/stylesheets/.gitkeep +0 -0
  250. data/vendor/assets/stylesheets/chosen.jquery.css +397 -0
  251. data/vendor/assets/stylesheets/modules/PIE.htc +96 -0
  252. data/vendor/assets/stylesheets/qtip.jquery.css.scss +604 -0
  253. data/vendor/plugins/.gitkeep +0 -0
  254. metadata +333 -0
@@ -0,0 +1,5 @@
1
+ module Smartkiosk
2
+ module Server
3
+ VERSION = '0.9.0'
4
+ end
5
+ end
@@ -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
@@ -0,0 +1,12 @@
1
+ class StringFile < StringIO
2
+ attr_accessor :filepath
3
+
4
+ def initialize(*args)
5
+ super(*args[1..-1])
6
+ @filepath = args[0]
7
+ end
8
+
9
+ def original_filename
10
+ File.basename(filepath)
11
+ end
12
+ end
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
@@ -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
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-Agent: *
5
+ # Disallow: /
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,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe SystemReceiptTemplatesController do
4
+
5
+ end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe TerminalBuildsController do
4
+
5
+ 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
@@ -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