Skip to content

Commit

Permalink
Added display_graph configuration variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Eli Fatsi committed Nov 8, 2013
1 parent 430de3a commit be81ffe
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ In `config/initializers/stat_board.rb`:
StatBoard.username = "user"
StatBoard.password = "pass"

3. Displaying Data Graphically (true by default)

StatBoard.display_graph = true

## Issues

* Models can be specified as strings rather than constants
Expand Down
4 changes: 3 additions & 1 deletion app/views/stat_board/stats/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
<%= render :partial => "chart", :collection => @reports, :as => :report %>
</div>

<%= render "graph" %>
<% if StatBoard.display_graph %>
<%= render "graph" %>
<% end %>
<% else %>
Please specify some models by setting <code>StatBoard.models</code>
Expand Down
5 changes: 4 additions & 1 deletion lib/stat_board.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
require "stat_board/reports/weekly_report"

module StatBoard
mattr_accessor :models, :title, :username, :password
mattr_accessor :models, :title, :display_graph, :username, :password

# Display graph by default. Can be disabled in initializers/stat_board.rb.
@@display_graph = true
end
9 changes: 8 additions & 1 deletion spec/requests/stat_board_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,18 @@
page.should have_content("Users")
end

it "sees the graph", :js => true do
it "sees the graph if display_graph is set to true", :js => true do
StatBoard.display_graph = true
visit "/stats"
page.should have_content("Highcharts.com")
end

it "does not see the graph if display_graph is set to false", :js => true do
StatBoard.display_graph = false
visit "/stats"
page.should_not have_content("Highcharts.com")
end

describe "with no records" do
before do
visit "/stats"
Expand Down

0 comments on commit be81ffe

Please sign in to comment.