Mercurial > zeropaste
annotate test/controllers/pastes_controller_test.rb @ 492:3038dddd33cb
Adjust build script (matches rails default)
author | nanaya <me@nanaya.net> |
---|---|
date | Tue, 17 Jan 2023 02:50:24 +0900 |
parents | 84ca55a0568e |
children |
rev | line source |
---|---|
298 | 1 require "test_helper" |
2 | |
3 class PastesControllerTest < ActionController::TestCase | |
314 | 4 test "creates paste from plaintext" do |
5 assert_difference("Paste.count", 1) do | |
435 | 6 post :create, :params => { "paste" => { "paste" => "here be paste" } } |
314 | 7 end |
8 | |
9 assert_response :redirect | |
10 end | |
11 | |
12 test "creates paste from gzip" do | |
13 assert_difference("Paste.count", 1) do | |
484
84ca55a0568e
Fix pasting base64 gzip and fix tests
nanaya <me@nanaya.pro>
parents:
435
diff
changeset
|
14 post :create, :params => { "paste" => { "paste_gzip" => fixture_file_upload('hello_world.txt.gz') } } |
314 | 15 end |
16 | |
17 assert_response :redirect | |
18 end | |
19 | |
315
325fcf388442
Another test for paste creation.
edogawaconan <me@myconan.net>
parents:
314
diff
changeset
|
20 test "creates paste from base64 gzip" do |
325fcf388442
Another test for paste creation.
edogawaconan <me@myconan.net>
parents:
314
diff
changeset
|
21 assert_difference("Paste.count", 1) do |
435 | 22 post :create, :params => { "paste" => { "paste_gzip_base64" => Base64.encode64(ActiveSupport::Gzip.compress("here be paste")) } } |
315
325fcf388442
Another test for paste creation.
edogawaconan <me@myconan.net>
parents:
314
diff
changeset
|
23 end |
325fcf388442
Another test for paste creation.
edogawaconan <me@myconan.net>
parents:
314
diff
changeset
|
24 |
325fcf388442
Another test for paste creation.
edogawaconan <me@myconan.net>
parents:
314
diff
changeset
|
25 assert_response :redirect |
325fcf388442
Another test for paste creation.
edogawaconan <me@myconan.net>
parents:
314
diff
changeset
|
26 end |
325fcf388442
Another test for paste creation.
edogawaconan <me@myconan.net>
parents:
314
diff
changeset
|
27 |
298 | 28 test "filters spam" do |
29 assert_no_difference("Paste.count") do | |
435 | 30 post :create, :params => { "url1" => "http://hello.com", "paste" => { "paste" => "here be paste", "key" => "12341234" } } |
298 | 31 end |
32 | |
33 assert_response :success | |
34 end | |
428
9fc6b919369c
Whoops, broken the very basic thing
nanaya <me@myconan.net>
parents:
315
diff
changeset
|
35 |
9fc6b919369c
Whoops, broken the very basic thing
nanaya <me@myconan.net>
parents:
315
diff
changeset
|
36 test "shows paste" do |
435 | 37 get :show, :params => { :id => pastes(:basic).id } |
428
9fc6b919369c
Whoops, broken the very basic thing
nanaya <me@myconan.net>
parents:
315
diff
changeset
|
38 |
9fc6b919369c
Whoops, broken the very basic thing
nanaya <me@myconan.net>
parents:
315
diff
changeset
|
39 assert_response :success |
9fc6b919369c
Whoops, broken the very basic thing
nanaya <me@myconan.net>
parents:
315
diff
changeset
|
40 end |
298 | 41 end |