Commit 763b2381198788d2d9d66f52b643903b5f6cc81f

Authored by Rafael Manzo
1 parent 3e00622d

Starting to test with Graphic JS

It successfully creates a instance of Grahic thanks to ejs templates.
Gemfile
... ... @@ -116,6 +116,9 @@ group :development, :test do
116 116  
117 117 # Mocks and stubs for javascript tests
118 118 gem 'sinon-rails'
  119 +
  120 + # JS templates for testing
  121 + gem 'ejs'
119 122 end
120 123  
121 124 # Acceptance tests
... ...
Gemfile.lock
... ... @@ -120,6 +120,7 @@ GEM
120 120 docile (1.1.5)
121 121 domain_name (0.5.24)
122 122 unf (>= 0.0.5, < 1.0.0)
  123 + ejs (1.1.1)
123 124 erubis (2.7.0)
124 125 exception_notification (4.0.1)
125 126 actionmailer (>= 3.0.4)
... ... @@ -343,6 +344,7 @@ DEPENDENCIES
343 344 dalli (~> 2.7.0)
344 345 database_cleaner (~> 1.4.1)
345 346 devise (~> 3.4.0)
  347 + ejs
346 348 exception_notification (~> 4.0.1)
347 349 factory_girl_rails (~> 4.5.0)
348 350 google-analytics-rails (~> 0.0.6)
... ...
spec/javascripts/module/graphic_spec.js.coffee 0 → 100644
... ... @@ -0,0 +1,16 @@
  1 +#= require jquery
  2 +#= require spec_helper
  3 +#= require modules
  4 +#= require module/graphic
  5 +
  6 +describe "Graphic#constructor", ->
  7 + describe 'with a visible drawer', ->
  8 + before () ->
  9 + @container = 'container404829'
  10 + @metric_name = 'Pain'
  11 + @module_id = '54405'
  12 + $('body').html(JST['templates/metric_results']({container: @container, metric_name: @metric_name, module_id: @module_id}))
  13 +
  14 + it "should construct a graphic", ->
  15 + graphic = new Module.Graphic(@container, @metric_name, @module_id)
  16 +
... ...
spec/javascripts/spec_helper.js.coffee 0 → 100644
... ... @@ -0,0 +1 @@
  1 +#= require_tree ./templates
... ...
spec/javascripts/templates/metric_results.jst.ejs 0 → 100644
... ... @@ -0,0 +1,27 @@
  1 +<table class="table table-hover metric_results">
  2 + <thead>
  3 + <tr>
  4 + <th>Metric</th>
  5 + <th>Value</th>
  6 + <th>Weight</th>
  7 + <th>Threshold</th>
  8 + </tr>
  9 + </thead>
  10 +
  11 + <tbody>
  12 + <tr>
  13 + <td><a onclick="new Module.Graphic('<%= container %>', '<%= metric_name %>', '<%= module_id %>')" id="metric_<%= module_id %>" data-remote="true" href=""><i class="icon-align-left"></i> Pain</a>
  14 + </td>
  15 + <td>4.20</td>
  16 + <td>3.0</td>
  17 + <td><span style="color: #00FF00">Excellent</span></td>
  18 + </tr>
  19 + <tr id="<%= container %>" style="">
  20 + <td colspan="4">
  21 + <span style="display: none;" id="loader_<%= container %>">Loading Data</span>
  22 + <canvas height="150" width="300" id="<%= container %>" class="graphic_container" style="width: 300px; height: 150px;"></canvas>
  23 + <span id="<%= container %>" style="display: none">There is only one point that should not generate a chart.</span>
  24 + </td>
  25 + </tr>
  26 + </tbody>
  27 +</table>
0 28 \ No newline at end of file
... ...