Commit e33399edc29f494eeaec2621d50c8b5307c52c76
Committed by
Rafael Manzo
1 parent
95684109
Exists in
colab
and in
4 other branches
Pending tests for graphic history done
Signed off by: Rafael Reggiani Manzo <rr.manzo@gmail.com>
Showing
2 changed files
with
6 additions
and
24 deletions
Show diff stats
app/controllers/modules_controller.rb
| ... | ... | @@ -3,7 +3,7 @@ class ModulesController < ApplicationController |
| 3 | 3 | |
| 4 | 4 | # POST /modules/1/metric_history |
| 5 | 5 | def metric_history |
| 6 | - module_result = ModuleResult.new({ id: params[:id] }) | |
| 6 | + module_result = ModuleResult.find(params[:id].to_i) | |
| 7 | 7 | @container = params[:container] |
| 8 | 8 | @metric_history = module_result.metric_history(params[:metric_name]) # pending: sort this hash. |
| 9 | 9 | end | ... | ... |
spec/controllers/modules_controller_spec.rb
| ... | ... | @@ -21,33 +21,15 @@ describe ModulesController do |
| 21 | 21 | let! (:module_result){ FactoryGirl.build(:module_result) } |
| 22 | 22 | |
| 23 | 23 | before :each do |
| 24 | - ModuleResult.expects(:new).at_least_once.with({id: module_result.id.to_s}).returns(module_result) | |
| 24 | + ModuleResult.expects(:find).at_least_once.with(module_result.id).returns(module_result) | |
| 25 | 25 | module_result.expects(:metric_history).with(metric_name).returns({date => metric_result.value}) |
| 26 | 26 | subject.expire_fragment("#{module_result.id}_#{metric_name}") |
| 27 | - end | |
| 28 | 27 | |
| 29 | - context "testing existence of the image in the response" do | |
| 30 | - it "should return an image" do | |
| 31 | - pending "It brokes with graphic caching" do | |
| 32 | - get :metric_history, id: module_result.id, metric_name: metric_name, module_id: module_id | |
| 33 | - response.content_type.should eq "image/png" | |
| 34 | - end | |
| 35 | - end | |
| 28 | + request.env["HTTP_ACCEPT"] = 'application/javascript' # FIXME: there should be a better way to force JS | |
| 29 | + get :metric_history, id: module_result.id, metric_name: metric_name, module_id: module_id | |
| 36 | 30 | end |
| 37 | 31 | |
| 38 | - context "testing parameter values" do | |
| 39 | - pending do | |
| 40 | - before :each do | |
| 41 | - @graphic = Gruff::Line.new(400) | |
| 42 | - Gruff::Line.expects(:new).with(400).returns(@graphic) | |
| 43 | - end | |
| 44 | - | |
| 45 | - it "should return two arrays, one of dates and other of values" do | |
| 46 | - get :metric_history, id: module_result.id, metric_name: metric_name, module_id: module_id | |
| 47 | - @graphic.maximum_value.should eq metric_result.value | |
| 48 | - @graphic.labels.first[1].should eq date.strftime("%Y/%m/%d") | |
| 49 | - end | |
| 50 | - end | |
| 51 | - end | |
| 32 | + it { should respond_with(:success) } | |
| 33 | + it { should render_template(:metric_history) } | |
| 52 | 34 | end |
| 53 | 35 | end |
| 54 | 36 | \ No newline at end of file | ... | ... |