Changeset 1243

Show
Ignore:
Timestamp:
2008-10-31 10:50:13 (2 months ago)
Author:
gaspard
Message:

commit 2659d858c575832309c21b2822a95a6704c040a0
Author: Gaspard Bucher <gaspard@teti.ch>

Fixed zazen links using sharp so that "link":34#id works like "link":34#zip or "link":34#. Same for "link":34#[parent/], "link":34#[parent/id] or "link":34#[parent/zip].

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/app/helpers/application_helper.rb

    r1242 r1243  
    451451        link_opts[:sharp_in] = sharp_in 
    452452      end 
    453       link_opts[:sharp]    = sharp 
     453      if ['[id]', '[zip]'].include?(sharp) 
     454        link_opts[:sharp] = 'true' 
     455      else 
     456        link_opts[:sharp] = sharp 
     457      end 
    454458    end 
    455459    if opts[:id] =~ /(\d+)(_\w+|)(\.\w+|)/ 
  • trunk/test/helpers/zazen_test.rb

    r1242 r1243  
    2929 
    3030  end 
    31  
     31   
    3232  def test_make_link 
    3333    login(:tiger) 
     
    3838    # * ["":034] if the node id starts with '0', creates a popup link. 
    3939    assert_match %r{/oo/projects/cleanWater.*window.open.*hello}, zazen('"hello":021') 
     40  end 
     41   
     42  def test_make_link_sharp 
     43    login(:tiger) 
     44    assert_equal '<p><a href="#node34">hello</a></p>', zazen('"hello":34#') 
     45    assert_equal '<p><a href="#node34">hello</a></p>', zazen('"hello":34#[id]') 
     46    assert_equal '<p><a href="#node34">hello</a></p>', zazen('"hello":34#[zip]') 
     47    assert_equal '<p><a href="#news">hello</a></p>', zazen('"hello":34#[name]') 
     48    # * ["":34#[parent/]] if the node id starts with '0', creates a popup link. 
     49    assert_equal '<p><a href="/oo/page32.html#node34">hello</a></p>', zazen('"hello":34#[parent/]') 
     50    assert_equal '<p><a href="/oo/page32.html#node34">hello</a></p>', zazen('"hello":34#[parent/id]') 
     51    assert_equal '<p><a href="/oo/page32.html#node34">hello</a></p>', zazen('"hello":34#[parent/zip]') 
     52    assert_equal '<p><a href="/oo/page32.html#news">hello</a></p>', zazen('"hello":34#[parent/name]') 
    4053  end 
    4154 
     
    158171    @node = secure!(Node) { nodes(:wiki) } 
    159172    assert_equal "<p>See <a href=\"/oo/projects/cleanWater\"><img src='/en/image30_med.jpg' width='220' height='200' alt='bird' class='med'/></a></p>", zazen('See !:(bird)_med!:(/projects/cleanWater)') 
     173  end 
     174   
     175  def test_bad_pseudo_path 
     176    login(:lion) 
     177    lion = secure!(Node) { nodes(:lion) } 
     178     
     179    @node = secure!(Node) { nodes(:cleanWater) } 
     180    assert_equal '<p>Read [(shmol) not found]</p>', zazen('Read "":(shmol)') 
     181    assert_equal 'Read "":(shmol)', zazen('Read "":(shmol)', :translate_ids => :zip, :node => lion) 
    160182  end 
    161183