annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
298
ff27821f9272 A test! Can you imagine that?!
edogawaconan <me@myconan.net>
parents:
diff changeset
1 require "test_helper"
ff27821f9272 A test! Can you imagine that?!
edogawaconan <me@myconan.net>
parents:
diff changeset
2
ff27821f9272 A test! Can you imagine that?!
edogawaconan <me@myconan.net>
parents:
diff changeset
3 class PastesControllerTest < ActionController::TestCase
314
3c22d4acc2fa Add basic controller test.
edogawaconan <me@myconan.net>
parents: 298
diff changeset
4 test "creates paste from plaintext" do
3c22d4acc2fa Add basic controller test.
edogawaconan <me@myconan.net>
parents: 298
diff changeset
5 assert_difference("Paste.count", 1) do
3c22d4acc2fa Add basic controller test.
edogawaconan <me@myconan.net>
parents: 298
diff changeset
6 post :create, "paste" => { "paste" => "here be paste" }
3c22d4acc2fa Add basic controller test.
edogawaconan <me@myconan.net>
parents: 298
diff changeset
7 end
3c22d4acc2fa Add basic controller test.
edogawaconan <me@myconan.net>
parents: 298
diff changeset
8
3c22d4acc2fa Add basic controller test.
edogawaconan <me@myconan.net>
parents: 298
diff changeset
9 assert_response :redirect
3c22d4acc2fa Add basic controller test.
edogawaconan <me@myconan.net>
parents: 298
diff changeset
10 end
3c22d4acc2fa Add basic controller test.
edogawaconan <me@myconan.net>
parents: 298
diff changeset
11
3c22d4acc2fa Add basic controller test.
edogawaconan <me@myconan.net>
parents: 298
diff changeset
12 test "creates paste from gzip" do
3c22d4acc2fa Add basic controller test.
edogawaconan <me@myconan.net>
parents: 298
diff changeset
13 assert_difference("Paste.count", 1) do
3c22d4acc2fa Add basic controller test.
edogawaconan <me@myconan.net>
parents: 298
diff changeset
14 post :create, "paste" => { "paste_gzip" => ActiveSupport::Gzip.compress("here be paste") }
3c22d4acc2fa Add basic controller test.
edogawaconan <me@myconan.net>
parents: 298
diff changeset
15 end
3c22d4acc2fa Add basic controller test.
edogawaconan <me@myconan.net>
parents: 298
diff changeset
16
3c22d4acc2fa Add basic controller test.
edogawaconan <me@myconan.net>
parents: 298
diff changeset
17 assert_response :redirect
3c22d4acc2fa Add basic controller test.
edogawaconan <me@myconan.net>
parents: 298
diff changeset
18 end
3c22d4acc2fa Add basic controller test.
edogawaconan <me@myconan.net>
parents: 298
diff changeset
19
298
ff27821f9272 A test! Can you imagine that?!
edogawaconan <me@myconan.net>
parents:
diff changeset
20 test "filters spam" do
ff27821f9272 A test! Can you imagine that?!
edogawaconan <me@myconan.net>
parents:
diff changeset
21 assert_no_difference("Paste.count") do
ff27821f9272 A test! Can you imagine that?!
edogawaconan <me@myconan.net>
parents:
diff changeset
22 post :create, "url1" => "http://hello.com", "paste" => { "paste" => "here be paste", "key" => "12341234" }
ff27821f9272 A test! Can you imagine that?!
edogawaconan <me@myconan.net>
parents:
diff changeset
23 end
ff27821f9272 A test! Can you imagine that?!
edogawaconan <me@myconan.net>
parents:
diff changeset
24
ff27821f9272 A test! Can you imagine that?!
edogawaconan <me@myconan.net>
parents:
diff changeset
25 assert_response :success
ff27821f9272 A test! Can you imagine that?!
edogawaconan <me@myconan.net>
parents:
diff changeset
26 end
ff27821f9272 A test! Can you imagine that?!
edogawaconan <me@myconan.net>
parents:
diff changeset
27 end