comparison test/controllers/pastes_controller_test.rb @ 314:3c22d4acc2fa

Add basic controller test.
author edogawaconan <me@myconan.net>
date Sat, 05 Apr 2014 23:08:49 +0900
parents ff27821f9272
children 325fcf388442
comparison
equal deleted inserted replaced
313:cc4171e52bb3 314:3c22d4acc2fa
1 require "test_helper" 1 require "test_helper"
2 2
3 class PastesControllerTest < ActionController::TestCase 3 class PastesControllerTest < ActionController::TestCase
4 test "creates paste from plaintext" do
5 assert_difference("Paste.count", 1) do
6 post :create, "paste" => { "paste" => "here be paste" }
7 end
8
9 assert_response :redirect
10 end
11
12 test "creates paste from gzip" do
13 assert_difference("Paste.count", 1) do
14 post :create, "paste" => { "paste_gzip" => ActiveSupport::Gzip.compress("here be paste") }
15 end
16
17 assert_response :redirect
18 end
19
4 test "filters spam" do 20 test "filters spam" do
5 assert_no_difference("Paste.count") do 21 assert_no_difference("Paste.count") do
6 post :create, "url1" => "http://hello.com", "paste" => { "paste" => "here be paste", "key" => "12341234" } 22 post :create, "url1" => "http://hello.com", "paste" => { "paste" => "here be paste", "key" => "12341234" }
7 end 23 end
8 24