You are here: Home > Latest news from Darcs > Avoids error when viewing previous revisions while logged in

Revision 20080415233825-9043f-2471e3...

Avoids error when viewing previous revisions while logged in

Revisions now respond to 'editable_by?' message

Fixes ErroNaVisualizacaoDoHistorico

app/models/revision.rb
test/fixtures/pages.yml
test/fixtures/revisions.yml
test/unit/revision_test.rb

Changes to revision.rb

23
  %w{name original_author revisions}.each do |method|
  %w{name original_author revisions}.each do |method|
23
24
    define_method(method) { page.send(method) }
    define_method(method) { page.send(method) }
24
25
  end
  end
25
 
26
 
  def editable_by?(user) page.editable_by?(user) end
27
26
  
  
28
27
  def diff(other)
  def diff(other)
29
28
    ChunkDiffer.new.diff(text.split($/),
    ChunkDiffer.new.diff(text.split($/),
30

Changes to pages.yml

86
  kind: common
  kind: common
86
87
  modified_at: 2008-04-01 19:23:42
  modified_at: 2008-04-01 19:23:42
87
88
88
 
open_page:
89
 
  id: 17
90
 
  name: OpenPage
91
 
  kind: common
92
 
  modified_at: 2008-04-15 20:11:08
93
 
94

Changes to revisions.yml

249
        
        
249
250
        Não há erro sintático na versão em português
        Não há erro sintático na versão em português
250
251
251
 
open_page_creation:
252
 
  id: 23
253
 
  page_id: 17
254
 
  kind: common
255
 
  modified_at: 2008-04-15 20:11:08
256
 
  last_editor_id: 1000004 #john
257
 
  editors: "john"
258
 
  title: Restricted page
259
 
  text: This page can only be edited by john himself.
260
 
  position: 1
261
 
262
 
first_open_page_edition:
263
 
  id: 24
264
 
  page_id: 17
265
 
  kind: common
266
 
  modified_at: 2008-04-15 20:14:53
267
 
  last_editor_id: 1000004 #john
268
 
  editors: "john bob"
269
 
  title: Open page
270
 
  text: John changed the editors list and now the page can be edited by Eric too
271
 
  position: 2
272
 
273
 
second_open_page_edition:
274
 
  id: 25
275
 
  page_id: 17
276
 
  kind: common
277
 
  modified_at: 2008-04-15 20:16:33
278
 
  last_editor_id: 1000001 #bob
279
 
  editors: "john bob"
280
 
  title: Open page
281
 
  text: Bob changed the text that John entered
282
 
  position: 3
283
 
284

Changes to revision_test.rb

34
    
    
34
35
    assert_equal rev.page.revisions, rev.revisions
    assert_equal rev.page.revisions, rev.revisions
35
36
  end
  end
36
 
37
 
  def test_revision_is_editable_by_current_page_editors
38
 
    assert revisions('second_open_page_edition').editable_by?(bob)
39
 
    assert revisions('open_page_creation').editable_by?(bob)
40
 
  end
41
37
  
  
42
38
  def test_diffs_one_line_modification
  def test_diffs_one_line_modification
43
39
    fst_rev = pages('changed_page').revisions[0]
    fst_rev = pages('changed_page').revisions[0]
44