changeset 428:9fc6b919369c

Whoops, broken the very basic thing Added test.
author nanaya <me@myconan.net>
date Sun, 15 Nov 2015 15:10:01 +0900
parents cbfb3a0a9d2e
children cc3f6f2e6efc
files app/models/paste.rb test/controllers/pastes_controller_test.rb test/fixtures/pastes.yml
diffstat 3 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/app/models/paste.rb	Sat Nov 14 20:43:49 2015 +0900
+++ b/app/models/paste.rb	Sun Nov 15 15:10:01 2015 +0900
@@ -17,7 +17,7 @@
   def self.safe_find(raw_id)
     /\A(?<id>[0-9]+)(?:-(?<secret>[0-9a-f]+))?\z/ =~ raw_id.to_s
 
-    where(:secret => secret, :id => id)
+    where(:secret => secret, :id => id).take
   end
 
   def self.graceful_create(params)
--- a/test/controllers/pastes_controller_test.rb	Sat Nov 14 20:43:49 2015 +0900
+++ b/test/controllers/pastes_controller_test.rb	Sun Nov 15 15:10:01 2015 +0900
@@ -32,4 +32,10 @@
 
     assert_response :success
   end
+
+  test "shows paste" do
+    get :show, :id => pastes(:basic).id
+
+    assert_response :success
+  end
 end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/fixtures/pastes.yml	Sun Nov 15 15:10:01 2015 +0900
@@ -0,0 +1,5 @@
+basic:
+  paste: hello, world!
+  ip: 127.0.0.1
+  key: 00000000
+  paste_hash: 8b79c03ccb15265150cab1a7f3f61e0abb397c977fad9e51b4a0b0d8d6b9d881ac8ab33007ea6e632fda8f2c4ba0ee9ada322d6cb18be2d87948d4f9b1faf1a2