diff --git a/app/controllers/modules_controller.rb b/app/controllers/modules_controller.rb index df03adb..399ffb9 100644 --- a/app/controllers/modules_controller.rb +++ b/app/controllers/modules_controller.rb @@ -3,7 +3,7 @@ class ModulesController < ApplicationController # POST /modules/1/metric_history def metric_history - module_result = ModuleResult.new({ id: params[:id] }) + module_result = ModuleResult.find(params[:id].to_i) @container = params[:container] @metric_history = module_result.metric_history(params[:metric_name]) # pending: sort this hash. end diff --git a/spec/controllers/modules_controller_spec.rb b/spec/controllers/modules_controller_spec.rb index 423770c..dd44547 100644 --- a/spec/controllers/modules_controller_spec.rb +++ b/spec/controllers/modules_controller_spec.rb @@ -21,33 +21,15 @@ describe ModulesController do let! (:module_result){ FactoryGirl.build(:module_result) } before :each do - ModuleResult.expects(:new).at_least_once.with({id: module_result.id.to_s}).returns(module_result) + ModuleResult.expects(:find).at_least_once.with(module_result.id).returns(module_result) module_result.expects(:metric_history).with(metric_name).returns({date => metric_result.value}) subject.expire_fragment("#{module_result.id}_#{metric_name}") - end - context "testing existence of the image in the response" do - it "should return an image" do - pending "It brokes with graphic caching" do - get :metric_history, id: module_result.id, metric_name: metric_name, module_id: module_id - response.content_type.should eq "image/png" - end - end + request.env["HTTP_ACCEPT"] = 'application/javascript' # FIXME: there should be a better way to force JS + get :metric_history, id: module_result.id, metric_name: metric_name, module_id: module_id end - context "testing parameter values" do - pending do - before :each do - @graphic = Gruff::Line.new(400) - Gruff::Line.expects(:new).with(400).returns(@graphic) - end - - it "should return two arrays, one of dates and other of values" do - get :metric_history, id: module_result.id, metric_name: metric_name, module_id: module_id - @graphic.maximum_value.should eq metric_result.value - @graphic.labels.first[1].should eq date.strftime("%Y/%m/%d") - end - end - end + it { should respond_with(:success) } + it { should render_template(:metric_history) } end end \ No newline at end of file -- libgit2 0.21.2