Permalink
Browse files

Fixes #6, also refactored support file naming

  • Loading branch information...
1 parent 9b3290a commit 5026dd9298512d986f99bd07467f0d94ebb4ae7c @adamhunter adamhunter committed Feb 5, 2013
@@ -18,4 +18,4 @@
- row.each do |value|
%th= value
-= link_to 'Download CSV', dossier_report_path(:format => 'csv', :options => params[:options]), :class => 'download-csv'
+= link_to 'Download CSV', dossier_report_path(format: 'csv', options: report.options, report: report.class.report_name), class: 'download-csv'
@@ -1,5 +1,10 @@
-class SiteController
+class SiteController < ApplicationController
def index
render text: 'wooo!'
end
+
+ def report
+ report = EmployeeReport.new
+ render template: 'dossier/reports/show', locals: {report: report.run}
+ end
end
@@ -1,5 +1,4 @@
Rails.application.routes.draw do
- mount Dossier::Engine => "/dossier"
-
get 'woo' => 'site#index', as: 'woo'
+ get 'employee_report_custom_controller' => 'site#report', as: 'employee_report_custom_controller'
end
@@ -1,8 +1,5 @@
if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
begin
- rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
- rvm_lib_path = File.join(rvm_path, 'lib')
- $LOAD_PATH.unshift rvm_lib_path
require 'rvm'
RVM.use_from_path! File.dirname(File.dirname(__FILE__))
rescue LoadError
@@ -47,7 +47,7 @@
</tr>
</tbody>
</table>
-<a href="/reports/employee.csv" class="download-csv">Download CSV</a>
+<a href="/reports/employee.csv?" class="download-csv">Download CSV</a>
</body>
@@ -47,7 +47,7 @@
</tr>
</tbody>
</table>
-<a href="/reports/employee_with_custom_client.csv" class="download-csv">Download CSV</a>
+<a href="/reports/employee_with_custom_client.csv?" class="download-csv">Download CSV</a>
</body>
@@ -0,0 +1,13 @@
+require 'spec_helper'
+
+describe "EmployeeReport with custom controller" do
+
+ describe "rendering HTML" do
+
+ it "builds a report using the specified client's database" do
+ get "/employee_report_custom_controller"
+ expect(response.body).to eq(File.read('spec/fixtures/reports/employee.html'))
+ end
+
+ end
+end
File renamed without changes.

0 comments on commit 5026dd9

Please sign in to comment.