extface 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +34 -0
  5. data/app/assets/javascripts/extface/application.js +13 -0
  6. data/app/assets/javascripts/extface/devices.js +2 -0
  7. data/app/assets/javascripts/extface/jobs.js +17 -0
  8. data/app/assets/stylesheets/extface/application.css +13 -0
  9. data/app/assets/stylesheets/extface/devices.css +4 -0
  10. data/app/assets/stylesheets/extface/jobs.css +4 -0
  11. data/app/assets/stylesheets/extface/sse.css +4 -0
  12. data/app/assets/stylesheets/scaffold.css +56 -0
  13. data/app/controllers/extface/application_controller.rb +21 -0
  14. data/app/controllers/extface/devices_controller.rb +69 -0
  15. data/app/controllers/extface/handler_controller.rb +66 -0
  16. data/app/controllers/extface/jobs_controller.rb +30 -0
  17. data/app/helpers/extface/application_helper.rb +40 -0
  18. data/app/helpers/extface/devices_helper.rb +21 -0
  19. data/app/helpers/extface/jobs_helper.rb +4 -0
  20. data/app/helpers/extface/sse_helper.rb +4 -0
  21. data/app/models/extface/device.rb +47 -0
  22. data/app/models/extface/driver/datecs_fp550.rb +6 -0
  23. data/app/models/extface/driver/fixed_width_serial_cdr.rb +6 -0
  24. data/app/models/extface/driver/generic_pos.rb +7 -0
  25. data/app/models/extface/driver/raw_serial.rb +27 -0
  26. data/app/models/extface/driver/star_scp700.rb +16 -0
  27. data/app/models/extface/driver/star_tsp200.rb +6 -0
  28. data/app/models/extface/driver_base.rb +67 -0
  29. data/app/models/extface/fiscal_print_driver.rb +8 -0
  30. data/app/models/extface/job.rb +54 -0
  31. data/app/models/extface/pbx_cdr_driver.rb +12 -0
  32. data/app/models/extface/pos_print_driver.rb +45 -0
  33. data/app/models/extface/raw_driver.rb +16 -0
  34. data/app/models/extface/serial_config.rb +10 -0
  35. data/app/views/extface/application/_object_errors.html.erb +10 -0
  36. data/app/views/extface/devices/form.html.erb +46 -0
  37. data/app/views/extface/devices/index.html.erb +36 -0
  38. data/app/views/extface/devices/show.html.erb +56 -0
  39. data/app/views/extface/driver/fixed_width_serial_cdr/_settings.html.erb +0 -0
  40. data/app/views/extface/driver/star_scp700/_settings.html.erb +1 -0
  41. data/app/views/extface/jobs/_form.html.erb +21 -0
  42. data/app/views/extface/jobs/edit.html.erb +6 -0
  43. data/app/views/extface/jobs/index.html.erb +27 -0
  44. data/app/views/extface/jobs/new.html.erb +5 -0
  45. data/app/views/extface/jobs/show.html.erb +9 -0
  46. data/app/views/extface/serial_configs/_settings.html.erb +37 -0
  47. data/app/views/layouts/extface/application.html.erb +14 -0
  48. data/config/routes.rb +12 -0
  49. data/db/migrate/20140215192111_create_extface_devices.rb +12 -0
  50. data/db/migrate/20140216110018_create_extface_pos_print_drivers.rb +9 -0
  51. data/db/migrate/20140216110608_create_extface_serial_configs.rb +14 -0
  52. data/db/migrate/20140216131245_create_extface_raw_drivers.rb +9 -0
  53. data/db/migrate/20140216131457_create_extface_fiscal_print_drivers.rb +9 -0
  54. data/db/migrate/20140216134748_create_extface_pbx_cdr_drivers.rb +9 -0
  55. data/db/migrate/20140219091811_create_extface_jobs.rb +9 -0
  56. data/db/migrate/20140219175006_add_job_info_to_extface_jobs.rb +9 -0
  57. data/lib/extface.rb +34 -0
  58. data/lib/extface/engine.rb +17 -0
  59. data/lib/extface/extfaceable.rb +17 -0
  60. data/lib/extface/mapping.rb +31 -0
  61. data/lib/extface/routes.rb +8 -0
  62. data/lib/extface/version.rb +3 -0
  63. data/lib/tasks/extface_tasks.rake +4 -0
  64. data/test/controllers/extface/devices_controller_test.rb +51 -0
  65. data/test/controllers/extface/jobs_controller_test.rb +14 -0
  66. data/test/dummy/README.rdoc +28 -0
  67. data/test/dummy/Rakefile +6 -0
  68. data/test/dummy/app/assets/javascripts/application.js +13 -0
  69. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  70. data/test/dummy/app/controllers/application_controller.rb +5 -0
  71. data/test/dummy/app/helpers/application_helper.rb +2 -0
  72. data/test/dummy/app/models/shop.rb +3 -0
  73. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  74. data/test/dummy/bin/bundle +3 -0
  75. data/test/dummy/bin/rails +4 -0
  76. data/test/dummy/bin/rake +4 -0
  77. data/test/dummy/config.ru +4 -0
  78. data/test/dummy/config/application.rb +24 -0
  79. data/test/dummy/config/boot.rb +5 -0
  80. data/test/dummy/config/database.yml +25 -0
  81. data/test/dummy/config/environment.rb +5 -0
  82. data/test/dummy/config/environments/development.rb +29 -0
  83. data/test/dummy/config/environments/production.rb +80 -0
  84. data/test/dummy/config/environments/test.rb +36 -0
  85. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  86. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  87. data/test/dummy/config/initializers/inflections.rb +16 -0
  88. data/test/dummy/config/initializers/mime_types.rb +5 -0
  89. data/test/dummy/config/initializers/secret_token.rb +12 -0
  90. data/test/dummy/config/initializers/session_store.rb +3 -0
  91. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  92. data/test/dummy/config/locales/en.yml +23 -0
  93. data/test/dummy/config/routes.rb +7 -0
  94. data/test/dummy/db/development.sqlite3 +0 -0
  95. data/test/dummy/db/migrate/20140221203517_create_shops.rb +8 -0
  96. data/test/dummy/db/schema.rb +83 -0
  97. data/test/dummy/db/test.sqlite3 +0 -0
  98. data/test/dummy/log/development.log +57 -0
  99. data/test/dummy/log/test.log +5908 -0
  100. data/test/dummy/public/404.html +58 -0
  101. data/test/dummy/public/422.html +58 -0
  102. data/test/dummy/public/500.html +57 -0
  103. data/test/dummy/public/favicon.ico +0 -0
  104. data/test/dummy/tmp/cache/assets/test/sprockets/0a8a23b1a73ebf217f4e2b765013ce7b +0 -0
  105. data/test/dummy/tmp/cache/assets/test/sprockets/21fb58a50e25d1170f2c7d5bd5d29c54 +0 -0
  106. data/test/dummy/tmp/cache/assets/test/sprockets/263375f2d55c31687ed052f99ddead55 +0 -0
  107. data/test/dummy/tmp/cache/assets/test/sprockets/3f4ff460a79b2e29781690193a3960f6 +0 -0
  108. data/test/dummy/tmp/cache/assets/test/sprockets/4ef10b222fde3c042209a46daf3d3e36 +0 -0
  109. data/test/dummy/tmp/cache/assets/test/sprockets/544650645bc510ef8fbee0043c41fdcf +0 -0
  110. data/test/dummy/tmp/cache/assets/test/sprockets/6dbf2b0443792e51055710be15c83197 +0 -0
  111. data/test/dummy/tmp/cache/assets/test/sprockets/717acb3e7c0df18696cf1bc56de6d3d5 +0 -0
  112. data/test/dummy/tmp/cache/assets/test/sprockets/9891cbb0808f38b2c42f42fd89e662a4 +0 -0
  113. data/test/dummy/tmp/cache/assets/test/sprockets/9b178820b9dc8c81c9784cf7ee3b7d35 +0 -0
  114. data/test/dummy/tmp/cache/assets/test/sprockets/a06a4a7f51754a6a2c0694eb39ff824b +0 -0
  115. data/test/dummy/tmp/cache/assets/test/sprockets/a8cc2e73253025d2518d2449e16e5266 +0 -0
  116. data/test/dummy/tmp/cache/assets/test/sprockets/b56dfad0b14283f2cc10c62f37d71cc7 +0 -0
  117. data/test/dummy/tmp/cache/assets/test/sprockets/e1197e0129ade843b08de0b45c47fc40 +0 -0
  118. data/test/dummy/tmp/cache/assets/test/sprockets/ece3270b150db7c668579bb91ac7e2e5 +0 -0
  119. data/test/dummy/tmp/cache/assets/test/sprockets/f018ab87f3490dbbcbc2e3c9f36aed3d +0 -0
  120. data/test/extface_test.rb +7 -0
  121. data/test/fixtures/extface/devices.yml +13 -0
  122. data/test/fixtures/extface/fiscal_print_drivers.yml +7 -0
  123. data/test/fixtures/extface/jobs.yml +7 -0
  124. data/test/fixtures/extface/pbx_cdr_drivers.yml +7 -0
  125. data/test/fixtures/extface/pos_print_drivers.yml +7 -0
  126. data/test/fixtures/extface/raw_drivers.yml +7 -0
  127. data/test/fixtures/extface/serial_configs.yml +17 -0
  128. data/test/fixtures/shops.yml +11 -0
  129. data/test/helpers/extface/devices_helper_test.rb +6 -0
  130. data/test/helpers/extface/jobs_helper_test.rb +6 -0
  131. data/test/helpers/extface/sse_helper_test.rb +6 -0
  132. data/test/integration/navigation_test.rb +10 -0
  133. data/test/models/extface/device_test.rb +9 -0
  134. data/test/models/extface/driver/star_tsp200_test.rb +9 -0
  135. data/test/models/extface/driver_test.rb +9 -0
  136. data/test/models/extface/fiscal_print_driver_test.rb +9 -0
  137. data/test/models/extface/job_test.rb +9 -0
  138. data/test/models/extface/pbx_cdr_driver_test.rb +9 -0
  139. data/test/models/extface/pos_print_driver_test.rb +9 -0
  140. data/test/models/extface/raw_driver_test.rb +9 -0
  141. data/test/models/extface/serial_config_test.rb +9 -0
  142. data/test/test_helper.rb +29 -0
  143. metadata +322 -0
@@ -0,0 +1,56 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <strong>Uuid:</strong>
5
+ <%= @device.uuid %>
6
+ </p>
7
+
8
+ <p>
9
+ <strong>Name:</strong>
10
+ <%= @device.name %>
11
+ </p>
12
+
13
+ <p>
14
+ <strong>Extfaceable:</strong>
15
+ <%= @device.extfaceable %>
16
+ </p>
17
+
18
+ <p>
19
+ <strong>Driveable:</strong>
20
+ <%= @device.driveable %>
21
+ </p>
22
+
23
+ <%= link_to 'Edit', edit_device_path(@device) %> |
24
+ <%= link_to 'Back', devices_path %>
25
+ <br />
26
+ Client Pull URL:
27
+ <br />
28
+ <%= extface.pull_url(@device.uuid) %>
29
+ <br />
30
+ <%= link_to 'Print Test Page', test_page_device_path(@device), remote:true %>
31
+
32
+
33
+ <h1>Jobs</h1>
34
+ <table class='table'>
35
+ <thead>
36
+ <tr class='active'>
37
+ <th>Id</th>
38
+ <th>Created</th>
39
+ <th>Description</th>
40
+ <th>Error</th>
41
+ <th>Failed</th>
42
+ <th>Completed</th>
43
+ <th>Connected</th>
44
+ </tr>
45
+ </thead>
46
+ <% @device.jobs.last(10).each do |job|%>
47
+ <tr>
48
+ <td><%= job.id %></td>
49
+ <td><%= job.created_at %></td>
50
+ <td><%= job.description %></td>
51
+ <td><%= job.error %></td>
52
+ <td><%= job.failed_at %></td>
53
+ <td><%= job.completed_at %></td>
54
+ <td><%= job.connected_at %></td>
55
+ </tr>
56
+ <% end %>
@@ -0,0 +1 @@
1
+ <%= __FILE__.gsub(Rails.root.to_s, "") %>
@@ -0,0 +1,21 @@
1
+ <%= form_for(@job) do |f| %>
2
+ <% if @job.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@job.errors.count, "error") %> prohibited this job from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @job.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :device_id %><br>
16
+ <%= f.text_field :device_id %>
17
+ </div>
18
+ <div class="actions">
19
+ <%= f.submit %>
20
+ </div>
21
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing job</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @job %> |
6
+ <%= link_to 'Back', jobs_path %>
@@ -0,0 +1,27 @@
1
+ <h1>Listing jobs</h1>
2
+
3
+ <table>
4
+ <thead>
5
+ <tr>
6
+ <th>Device</th>
7
+ <th></th>
8
+ <th></th>
9
+ <th></th>
10
+ </tr>
11
+ </thead>
12
+
13
+ <tbody>
14
+ <% @jobs.each do |job| %>
15
+ <tr>
16
+ <td><%= job.device %></td>
17
+ <td><%= link_to 'Show', job %></td>
18
+ <td><%= link_to 'Edit', edit_job_path(job) %></td>
19
+ <td><%= link_to 'Destroy', job, method: :delete, data: { confirm: 'Are you sure?' } %></td>
20
+ </tr>
21
+ <% end %>
22
+ </tbody>
23
+ </table>
24
+
25
+ <br>
26
+
27
+ <%= link_to 'New Job', new_job_path %>
@@ -0,0 +1,5 @@
1
+ <h1>New job</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', jobs_path %>
@@ -0,0 +1,9 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <strong>Device:</strong>
5
+ <%= @job.device %>
6
+ </p>
7
+
8
+ <%= link_to 'Edit', edit_job_path(@job) %> |
9
+ <%= link_to 'Back', jobs_path %>
@@ -0,0 +1,37 @@
1
+ <div class='panel panel-default'>
2
+ <div class="panel-heading">
3
+ <h3 class="panel-title"><%= t('.serial_settings') %></h3>
4
+ </div>
5
+ <div class='panel-body'>
6
+ <div class="form-group">
7
+ <%= f.label :boud_rate, class: 'col-sm-2 control-label' %>
8
+ <div class='col-sm-8'>
9
+ <%= f.select :serial_boud_rate, Extface::SerialConfig::BOUD_RATES, { include_blank: true }, class: 'form-control' %>
10
+ </div>
11
+ </div>
12
+ <div class="form-group">
13
+ <%= f.label :data_length, class: 'col-sm-2 control-label' %>
14
+ <div class='col-sm-8'>
15
+ <%= f.select :serial_data_length, Extface::SerialConfig::DATA_LENGTHS, { include_blank: true }, class: 'form-control' %>
16
+ </div>
17
+ </div>
18
+ <div class="form-group">
19
+ <%= f.label :parity_check, class: 'col-sm-2 control-label' %>
20
+ <div class='col-sm-8'>
21
+ <%= f.select :serial_parity_check, Extface::SerialConfig::PARITY_CHECKS, { include_blank: true }, class: 'form-control' %>
22
+ </div>
23
+ </div>
24
+ <div class="form-group">
25
+ <%= f.label :stop_bits, class: 'col-sm-2 control-label' %>
26
+ <div class='col-sm-8'>
27
+ <%= f.select :serial_stop_bits, Extface::SerialConfig::STOP_BITS, { include_blank: true }, class: 'form-control' %>
28
+ </div>
29
+ </div>
30
+ <div class="form-group">
31
+ <%= f.label :handshake, class: 'col-sm-2 control-label' %>
32
+ <div class='col-sm-8'>
33
+ <%= f.select :serial_handshake, Extface::SerialConfig::HANDSHAKE, { include_blank: true }, class: 'form-control' %>
34
+ </div>
35
+ </div>
36
+ </div>
37
+ </div>
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Extface</title>
5
+ <%= stylesheet_link_tag "extface/application", media: "all" %>
6
+ <%= javascript_include_tag "extface/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
data/config/routes.rb ADDED
@@ -0,0 +1,12 @@
1
+ Extface::Engine.routes.draw do
2
+ resources :jobs
3
+
4
+ resources :devices do
5
+ resources :jobs, only: [:show]
6
+ get :test_page, on: :member
7
+ end
8
+
9
+ get ':device_uuid' => 'handler#pull', as: :pull
10
+ post ':device_uuid' => 'handler#push', as: :push
11
+ root 'devices#index'
12
+ end
@@ -0,0 +1,12 @@
1
+ class CreateExtfaceDevices < ActiveRecord::Migration
2
+ def change
3
+ create_table :extface_devices do |t|
4
+ t.string :uuid
5
+ t.string :name
6
+ t.references :extfaceable, polymorphic: true
7
+ t.references :driveable, polymorphic: true, index: true
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,9 @@
1
+ class CreateExtfacePosPrintDrivers < ActiveRecord::Migration
2
+ def change
3
+ create_table :extface_pos_print_drivers do |t|
4
+ t.string :type
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ class CreateExtfaceSerialConfigs < ActiveRecord::Migration
2
+ def change
3
+ create_table :extface_serial_configs do |t|
4
+ t.references :s_configureable, polymorphic: true
5
+ t.integer :serial_boud_rate
6
+ t.integer :serial_data_length
7
+ t.integer :serial_parity_check
8
+ t.integer :serial_stop_bits
9
+ t.integer :serial_handshake
10
+
11
+ t.timestamps
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+ class CreateExtfaceRawDrivers < ActiveRecord::Migration
2
+ def change
3
+ create_table :extface_raw_drivers do |t|
4
+ t.string :type
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class CreateExtfaceFiscalPrintDrivers < ActiveRecord::Migration
2
+ def change
3
+ create_table :extface_fiscal_print_drivers do |t|
4
+ t.string :type
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class CreateExtfacePbxCdrDrivers < ActiveRecord::Migration
2
+ def change
3
+ create_table :extface_pbx_cdr_drivers do |t|
4
+ t.string :type
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class CreateExtfaceJobs < ActiveRecord::Migration
2
+ def change
3
+ create_table :extface_jobs do |t|
4
+ t.belongs_to :device, index: true
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class AddJobInfoToExtfaceJobs < ActiveRecord::Migration
2
+ def change
3
+ add_column :extface_jobs, :description, :string
4
+ add_column :extface_jobs, :error, :string
5
+ add_column :extface_jobs, :failed_at, :timestamp
6
+ add_column :extface_jobs, :completed_at, :timestamp
7
+ add_column :extface_jobs, :connected_at, :timestamp
8
+ end
9
+ end
data/lib/extface.rb ADDED
@@ -0,0 +1,34 @@
1
+ require "extface/engine"
2
+ require "extface/routes"
3
+ require "extface/mapping"
4
+ require "extface/extfaceable"
5
+ module Extface
6
+ mattr_accessor :redis_connection_string
7
+
8
+ mattr_reader :mappings
9
+ @@mappings = ActiveSupport::OrderedHash.new
10
+
11
+ class << self
12
+ def add_mapping(resource, options)
13
+ mapping = Extface::Mapping.new(resource, options)
14
+ @@mappings[mapping.name] = mapping
15
+ end
16
+
17
+ def redis_block
18
+ r = Redis.new
19
+ begin
20
+ yield r
21
+ ensure
22
+ r.quit
23
+ end
24
+ end
25
+
26
+ private
27
+ def parse_redis_url
28
+ if @@redis_connection_string
29
+ uri = URI.parse(@@redis_connection_string)
30
+ return {:host => uri.host, :port => uri.port, :password => uri.password}
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,17 @@
1
+ require "redis"
2
+ module Extface
3
+ class Engine < ::Rails::Engine
4
+ isolate_namespace Extface
5
+
6
+ config.to_prepare do
7
+ # Thread.new do
8
+ # $redis.subscribe("extface") do |on|
9
+ # on.message do |channel, msg|
10
+ # #data = JSON.parse(msg)
11
+ # p "##{channel} - #{msg}"
12
+ # end
13
+ # end
14
+ # end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module Extface
2
+ module Extfaceable
3
+ extend ActiveSupport::Concern
4
+
5
+ def composite_id
6
+ "#{self.class.name}##{self.id}"
7
+ end
8
+
9
+ module ClassMethods
10
+ def has_extface_devices
11
+ has_many :extface_devices, class_name: 'Extface::Device', as: :extfaceable
12
+ end
13
+ end
14
+
15
+ end
16
+ end
17
+ ActiveRecord::Base.send :include, Extface::Extfaceable
@@ -0,0 +1,31 @@
1
+ module Extface
2
+ class Mapping
3
+ attr_reader :name, :i_klass, :i_param, :i_find_key, :i_extra_module
4
+ def initialize(resource, options)
5
+ @name = options[:as] || resource.to_s
6
+
7
+ @i_klass = (options[:interfaceable_type] || name.to_s.classify).to_s.constantize
8
+
9
+ @i_param = options[:interfaceable_param] || "#{name}_id" #default #{resource}_id
10
+
11
+ # key to find interfaceable in controller, when
12
+ # :uuid then find_by! :uuid => params[:uuid]
13
+ # :shop_uuid then find_by! :uuid => params[:shop_uuid]
14
+ # :shop_id then find_by! :id => params[:shop_id]
15
+ @i_find_key = @i_param[/^(#{@name}_|)(\w+)/,2]
16
+ raise "#{@i_klass.name} has no method #{@i_find_key}" unless @i_klass.new.respond_to? @i_find_key
17
+ raise "Did you forget to add 'has_extface_devices' in #{@i_klass.name} ?" unless @i_klass.new.respond_to? :extface_devices
18
+ @i_extra_module = options[:controller_include].to_s.constantize if options[:controller_include].present?
19
+ end
20
+
21
+ def mount_point
22
+ "#{name}_extface"
23
+ end
24
+
25
+ class << self
26
+ def find(fullpath)
27
+ Extface.mappings[fullpath[%r{/(\w+)_extface\/}, 1]]
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,8 @@
1
+ module ActionDispatch::Routing
2
+ class Mapper
3
+ def extface_for(resource, options = {})
4
+ mapping = Extface.add_mapping(resource, options)
5
+ mount Extface::Engine, at: mapping.mount_point
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ module Extface
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :extface do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,51 @@
1
+ require 'test_helper'
2
+
3
+ module Extface
4
+ class DevicesControllerTest < ActionController::TestCase
5
+ setup do
6
+ @device = extface_devices(:one)
7
+ end
8
+
9
+ test "should get index" do
10
+ get :index, shop_id: @device.extfaceable, use_route: :extface
11
+ assert_response :success
12
+ assert_not_nil assigns(:devices)
13
+ end
14
+
15
+ test "should get new" do
16
+ get :new, shop_id: @device.extfaceable, use_route: :extface
17
+ assert_response :success
18
+ end
19
+
20
+ test "should create device" do
21
+ assert_difference('Device.count') do
22
+ post :create, shop_id: @device.extfaceable, use_route: :extface, device: { driver: 'Extface::Driver::RawSerial' }
23
+ end
24
+
25
+ assert_redirected_to device_path(assigns(:device))
26
+ end
27
+
28
+ test "should show device" do
29
+ get :show, shop_id: @device.extfaceable, use_route: :extface, id: @device
30
+ assert_response :success
31
+ end
32
+
33
+ test "should get edit" do
34
+ get :edit, shop_id: @device.extfaceable, use_route: :extface, id: @device
35
+ assert_response :success
36
+ end
37
+
38
+ test "should update device" do
39
+ patch :update, shop_id: @device.extfaceable, use_route: :extface, id: @device, device: { name: :new_name }
40
+ assert_redirected_to device_path(assigns(:device))
41
+ end
42
+
43
+ test "should destroy device" do
44
+ assert_difference('Device.count', -1) do
45
+ delete :destroy, shop_id: @device.extfaceable, use_route: :extface, id: @device
46
+ end
47
+
48
+ assert_redirected_to devices_path
49
+ end
50
+ end
51
+ end