Skip to content

Commit f93be5c

Browse files
committed
Un peu plus de tests de models
1 parent 707b992 commit f93be5c

File tree

4 files changed

+60
-0
lines changed

4 files changed

+60
-0
lines changed

test/fixtures/diaries.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ old:
1111
owner: visitor_1
1212
body: Un si joli journal
1313
wiki_body: Un si joli journal
14+
created_at: <%= 4.months.ago %>
1415

1516
lorem_cc_licensed:
1617
title: Lorem ipsum

test/models/account_test.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,20 @@ class AccountTest < ActiveSupport::TestCase
44
def test_should_create_account
55
assert_difference 'Account.count' do
66
account = new_account
7+
78
assert account.save, account.errors.full_messages.to_sentence
89
end
910
end
1011

12+
test 'should get anonymous account' do
13+
assert Account.anonymous
14+
assert_equal 'Anonyme', Account.anonymous.login
15+
end
16+
1117
def test_should_require_login
1218
assert_no_difference 'Account.count' do
1319
account = new_account(login: nil)
20+
1421
assert_not account.save, account.errors.full_messages.to_sentence
1522
end
1623
end

test/models/content_test.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
require 'test_helper'
2+
3+
class ContentTest < ActiveSupport::TestCase
4+
test 'should not create naked content' do
5+
assert_raises NotImplementedError do
6+
Content.create
7+
end
8+
end
9+
10+
test 'should get label for expand' do
11+
assert_equal 'Lire la suite', Poll.first.label_for_expand
12+
end
13+
14+
test 'should get alternative formats' do
15+
assert Poll.first.alternative_formats
16+
assert_not Bookmark.first.alternative_formats
17+
end
18+
19+
test 'should get lastmod' do
20+
assert_equal polls(:one).updated_at, polls(:one).lastmod
21+
end
22+
23+
test 'should get changefreq' do
24+
assert_equal 'hourly', polls(:one).changefreq
25+
polls(:draft).created_at = 2.days.ago
26+
27+
assert_equal 'daily', polls(:draft).changefreq
28+
polls(:draft).created_at = 4.days.ago
29+
30+
assert_equal 'monthly', polls(:draft).changefreq
31+
assert_equal 'yearly', diaries(:old).changefreq
32+
end
33+
end

test/models/lang_test.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
require 'test_helper'
2+
3+
class LangTest < ActiveSupport::TestCase
4+
setup do
5+
$redis.del 'lang'
6+
$redis.del 'lang/fr'
7+
end
8+
9+
test 'should have no language' do
10+
assert_empty Lang.all
11+
end
12+
13+
test 'should add one language' do
14+
Lang['fr'] = 'Français'
15+
16+
assert_not_empty Lang.all
17+
assert 1, Lang.all.size
18+
end
19+
end

0 commit comments

Comments
 (0)