Commit 7712c7369d0d3a55458548641dd97919b9a4b03d
1 parent
892e18f7
Exists in
master
and in
29 other branches
ActionItem153: adding recent documents support for environments
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1281 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
4 changed files
with
29 additions
and
4 deletions
Show diff stats
app/controllers/admin/environment_design_controller.rb
app/models/environment.rb
test/functional/environment_design_controller_test.rb
... | ... | @@ -11,8 +11,7 @@ class EnvironmentDesignControllerTest < Test::Unit::TestCase |
11 | 11 | @response = ActionController::TestResponse.new |
12 | 12 | end |
13 | 13 | |
14 | - # Replace this with your real tests. | |
15 | - def test_truth | |
16 | - assert true | |
14 | + should 'have tests' do | |
15 | + flunk 'add some real test here' | |
17 | 16 | end |
18 | 17 | end | ... | ... |
test/unit/environment_test.rb
... | ... | @@ -219,4 +219,25 @@ class EnvironmentTest < Test::Unit::TestCase |
219 | 219 | assert(environment.blocks.any? { |block| block.kind_of? MainBlock }) |
220 | 220 | end |
221 | 221 | |
222 | + should 'provide recent_documents' do | |
223 | + environment = Environment.create(:name => 'a test environment') | |
224 | + | |
225 | + # p1 creates one article | |
226 | + p1 = environment.profiles.build(:identifier => 'testprofile1', :name => 'test profile 1') | |
227 | + p1.save! | |
228 | + doc1 = p1.articles.build(:name => 'text 1'); doc1.save! | |
229 | + | |
230 | + # p2 creates two articles | |
231 | + p2 = environment.profiles.build(:identifier => 'testprofile2', :name => 'test profile 2') | |
232 | + p2.save! | |
233 | + doc2 = p2.articles.build(:name => 'text 2'); doc2.save! | |
234 | + doc3 = p2.articles.build(:name => 'text 3'); doc3.save! | |
235 | + | |
236 | + # p1 creates another article | |
237 | + doc4 = p1.articles.build(:name => 'text 4'); doc4.save! | |
238 | + | |
239 | + assert_equivalent [doc1,doc2,doc3,doc4], environment.recent_documents | |
240 | + assert_equivalent [doc1,doc2,doc3], environment.recent_documents(3) | |
241 | + end | |
242 | + | |
222 | 243 | end | ... | ... |