prosperity 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/prosperity/application.css.scss +1 -1
  3. data/app/controllers/prosperity/dashboard_graphs_controller.rb +6 -2
  4. data/app/controllers/prosperity/graphs_controller.rb +9 -1
  5. data/app/models/prosperity/dashboard_graph.rb +2 -0
  6. data/app/views/layouts/prosperity/application.html.erb +1 -2
  7. data/app/views/prosperity/dashboards/show.html.erb +4 -0
  8. data/app/views/prosperity/graphs/_common_fields.html.erb +14 -0
  9. data/app/views/prosperity/graphs/edit.html.erb +2 -9
  10. data/app/views/prosperity/graphs/new.html.erb +1 -9
  11. data/app/views/prosperity/graphs/show.html.erb +6 -3
  12. data/lib/prosperity/version.rb +1 -1
  13. data/spec/controllers/prosperity/dashboard_graphs_controller_spec.rb +7 -0
  14. data/spec/controllers/prosperity/graphs_controller_spec.rb +6 -0
  15. data/spec/dummy/log/development.log +2863 -0
  16. data/spec/dummy/log/test.log +3900 -0
  17. data/spec/dummy/tmp/cache/assets/development/sass/34a577735054231563e7022ea73e1468db9203ba/application.css.scssc +0 -0
  18. data/spec/dummy/tmp/cache/assets/development/sprockets/210050da208fb75a75b701bfa4e8470f +0 -0
  19. data/spec/dummy/tmp/cache/assets/development/sprockets/a2b14d5c46db32da9183354fb3fcd0bf +0 -0
  20. data/spec/dummy/tmp/cache/assets/development/sprockets/a6d6196cfd275dea0718553a95f997a5 +0 -0
  21. data/spec/dummy/tmp/cache/assets/test/sass/34a577735054231563e7022ea73e1468db9203ba/application.css.scssc +0 -0
  22. data/spec/dummy/tmp/cache/assets/test/sprockets/210050da208fb75a75b701bfa4e8470f +0 -0
  23. data/spec/dummy/tmp/cache/assets/test/sprockets/a2b14d5c46db32da9183354fb3fcd0bf +0 -0
  24. data/spec/dummy/tmp/cache/assets/test/sprockets/a6d6196cfd275dea0718553a95f997a5 +0 -0
  25. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a5c67a59270ef33317323ebdc699936e5e89ac5f
4
- data.tar.gz: 21df5064d10dc796a58e8d7510ac7c0a0e26e5a6
3
+ metadata.gz: 4f2eef9c17ac3662933cc06b450f81f8d750daa7
4
+ data.tar.gz: e0f0f2ffd626b476d0d39ff2323fa08dcb51cbfd
5
5
  SHA512:
6
- metadata.gz: faf49f6e8fe66d517f58b6f53bd95280f1ebff3cb5673288d9db7da7f879fb072374d97e4d30eefb37a278840d657f15bbe59837eaa8191cc681e13b1b3c4680
7
- data.tar.gz: bfb5e793939e5d190935b0dde676a4ef7fdf07632e041245e111650519a0a47d141daff898f54edbf3f4c5ca18a7f237e0b70a33eef8dc040aa6a8bcab317b2e
6
+ metadata.gz: 2f5ed319d26cbfa9b49021f258d2b70c5628cd25e72d92bd0c0c675001c2350693e6ef15316a3ca060133d0c5187d29fd6667d862a0ec3157bbc469b16c58fa7
7
+ data.tar.gz: 1170f782cc52ecc0dfb604d9e7d6b717ff93f296946caaf3c5b19e233432c3d543fe334bea019b4c1f0cba21b2eae5f549c051cd47ec44e9567c9a55fcd5d342
@@ -16,5 +16,5 @@
16
16
  */
17
17
 
18
18
  .main {
19
- padding: 40px 15px;
19
+ padding: 60px 15px;
20
20
  }
@@ -4,8 +4,12 @@ module Prosperity
4
4
  class DashboardGraphsController < ApplicationController
5
5
  before_action :get_objs
6
6
  def create
7
- DashboardGraph.create!(graph: @graph, dashboard: @dashboard)
8
- redirect_to edit_dashboard_path(@dashboard)
7
+ dashboard_graph = DashboardGraph.new(graph: @graph, dashboard: @dashboard)
8
+
9
+ unless dashboard_graph.save
10
+ set_error(dashboard_graph)
11
+ end
12
+ redirect_to edit_dashboard_path(@dashboard)
9
13
  end
10
14
 
11
15
  def destroy
@@ -2,7 +2,7 @@ require_dependency "prosperity/application_controller"
2
2
 
3
3
  module Prosperity
4
4
  class GraphsController < ApplicationController
5
- before_action :get_graph, only: [:edit, :update, :show]
5
+ before_action :get_graph, only: [:edit, :update]
6
6
  def new
7
7
  @graph = Graph.new
8
8
  end
@@ -19,6 +19,7 @@ module Prosperity
19
19
  def show
20
20
  respond_to do |format|
21
21
  format.json do
22
+ get_graph
22
23
  render json: {
23
24
  title: @graph.title,
24
25
  graph_type: @graph.graph_type,
@@ -37,6 +38,13 @@ module Prosperity
37
38
  end
38
39
 
39
40
  format.html {
41
+ begin
42
+ get_graph
43
+ rescue ActiveRecord::RecordNotFound
44
+ @graph = nil
45
+ render layout: 'prosperity/embedabble', status: :not_found
46
+ return
47
+ end
40
48
  render layout: 'prosperity/embedabble'
41
49
  }
42
50
  end
@@ -2,5 +2,7 @@ module Prosperity
2
2
  class DashboardGraph < ActiveRecord::Base
3
3
  belongs_to :dashboard
4
4
  belongs_to :graph
5
+
6
+ validates :dashboard, uniqueness: {scope: :graph, message: "already contains this graph"}
5
7
  end
6
8
  end
@@ -37,8 +37,7 @@
37
37
  <div class="main">
38
38
  <% flash.each do |name, msg| %>
39
39
  <% if msg.is_a?(String) %>
40
- <div class="alert alert-<%= name == :notice ? "success" : "error" %>">
41
- <a class="close" data-dismiss="alert">&#215;</a>
40
+ <div class="alert alert-<%= name == :notice ? "success" : "danger" %>">
42
41
  <%= content_tag :div, msg, :id => "flash_#{name}" %>
43
42
  </div>
44
43
  <% end %>
@@ -16,3 +16,7 @@
16
16
  <div class="metric dashboard" data-url="<%= graph_path(graph, start_time: start_time) %>"></div>
17
17
  </div>
18
18
  <% end %>
19
+
20
+ <p>
21
+ <%= link_to "Edit this dashboard", edit_dashboard_path(@dashboard) %>
22
+ </p>
@@ -0,0 +1,14 @@
1
+ <div class="form-group">
2
+ <%= f.label :title %>
3
+ <%= f.text_field :title %>
4
+ </div>
5
+
6
+ <div class="form-group">
7
+ <%= f.label :graph_type %>
8
+ <%= f.select :graph_type, Prosperity::Graph::VALID_GRAPH_TYPES %>
9
+ </div>
10
+
11
+ <div class="form-group">
12
+ <%= f.label :period %>
13
+ <%= f.select :period, Prosperity::Periods::ALL.keys %>
14
+ </div>
@@ -3,15 +3,8 @@
3
3
  <div class="row">
4
4
  <div class="span6">
5
5
  <%= form_for @graph, data: {metric_options: @options} do |f| %>
6
- <div class="form-group">
7
- <%= f.label :title %>
8
- <%= f.text_field :title %>
9
- </div>
10
-
11
- <div class="form-group">
12
- <%= f.label :graph_type %>
13
- <%= f.select :graph_type, Prosperity::Graph::VALID_GRAPH_TYPES %>
14
- </div>
6
+
7
+ <%= render partial: 'common_fields', locals: {f: f} %>
15
8
 
16
9
  <h4>Lines</h4>
17
10
  <%= f.fields_for :graph_lines do |l| %>
@@ -1,15 +1,7 @@
1
1
  <h1>New Graph</h1>
2
2
 
3
3
  <%= form_for @graph, html: {role: 'form'} do |f| %>
4
- <div class="form-group">
5
- <%= f.label :title %>
6
- <%= f.text_field :title %>
7
- </div>
8
-
9
- <div class="form-group">
10
- <%= f.label :period %>
11
- <%= f.select :period, Prosperity::Periods::ALL.keys %>
12
- </div>
4
+ <%= render partial: 'common_fields', locals: {f: f} %>
13
5
 
14
6
  <%= f.submit "Save", class: 'btn btn-success' %>
15
7
  <% end %>
@@ -1,3 +1,6 @@
1
- <div class='metric-title'><%= @graph.title %></div>
2
- <div class="metric dashboard" data-url="<%= graph_path(@graph) %>"></div>
3
-
1
+ <% if @graph %>
2
+ <div class='metric-title'><%= @graph.title %></div>
3
+ <div class="metric dashboard" data-url="<%= graph_path(@graph) %>"></div>
4
+ <% else %>
5
+ <p>No such graph</p>
6
+ <% end %>
@@ -1,3 +1,3 @@
1
1
  module Prosperity
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -25,6 +25,13 @@ module Prosperity
25
25
  dg.graph.should == graph
26
26
  dg.dashboard.should == dashboard
27
27
  end
28
+
29
+ it "errors if you try to add the same graph twice" do
30
+ post :create, dashboard_id: dashboard.id, graph_id: graph.id
31
+ post :create, dashboard_id: dashboard.id, graph_id: graph.id
32
+ response.should redirect_to(edit_dashboard_path(dashboard))
33
+ flash[:error].should be_present
34
+ end
28
35
  end
29
36
 
30
37
  describe "DELETE 'destroy'" do
@@ -81,6 +81,12 @@ module Prosperity
81
81
  it "should render the embedabble layout" do
82
82
  response.body.should_not include('navbar')
83
83
  end
84
+
85
+ it "404 with custom page when graph is not found" do
86
+ get :show, id: :unknown_id, format: 'html'
87
+ response.status.should == 404
88
+ response.body.should include("No such graph")
89
+ end
84
90
  end
85
91
  end
86
92