Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Tests for slug enforcement

  • Loading branch information...
commit 95657c6ae571d60751056fdc5ed64a92b2efe7e7 1 parent 3fb315b
@sgtFloyd sgtFloyd authored
Showing with 10 additions and 0 deletions.
  1. +1 −0  lib/dashboard.rb
  2. +9 −0 test/lib/test_dashboard.rb
View
1  lib/dashboard.rb
@@ -6,6 +6,7 @@ class Dashboard
def self.save(slug = nil, json)
slug ||= json[:slug]
slug = "#{Time.now.to_f}".delete('.') if slug.nil? || slug.empty?
+ json[:slug] = slug
key = "dashboards:#{slug}"
redis.hset key, "title", json[:title]
redis.hset key, "slug", slug
View
9 test/lib/test_dashboard.rb
@@ -40,6 +40,15 @@ def test_saving_dashboard
assert_equal @dash_json, dash
end
+ def test_saving_dashboard_without_slug
+ dash = Dashboard.save({title: "dash without slug"})
+ assert dash[:slug]
+ dash = Dashboard.save({title: "dash with empty slug", slug: ''})
+ assert dash[:slug]
+ dash = Dashboard.save({title: "dash with nil slug", slug: nil})
+ assert dash[:slug]
+ end
+
def test_find_dashboard_with_graphs
assert Dashboard.save(@dash_json)
assert Dashboard.add_graph(@dash_json[:slug], @graph_uuid)
Please sign in to comment.
Something went wrong with that request. Please try again.