Adding new browse controller test, which is mostly stubs just now. Also adding the...
authorShaun McDonald <shaun@shaunmcdonald.me.uk>
Tue, 21 Oct 2008 16:18:18 +0000 (16:18 +0000)
committerShaun McDonald <shaun@shaunmcdonald.me.uk>
Tue, 21 Oct 2008 16:18:18 +0000 (16:18 +0000)
app/views/browse/index.rhtml
test/functional/browse_controller_test.rb [new file with mode: 0644]

index 2cd5cc9da4c09c1f46655033c93042bc0e94bb5f..e9d830a1063d511fc43e0a81a2adcb172e70c128 100644 (file)
@@ -1,11 +1,11 @@
 <h2><%= @nodes.length %> Recently Changed Nodes</h2> 
-<ul>
+<ul id="recently_changed">
 <% @nodes.each do |node| 
    name = node.tags_as_hash['name'].to_s 
    if name.length == 0:
      name = "(No name)"
    end
-   name = name + " - " + node.id.to_s 
+   name = "#{name} - #{node.id} (#{node.version})"
 %>
    <li><%= link_to h(name), :action => "node", :id => node.id %></li>
 <% end %>
diff --git a/test/functional/browse_controller_test.rb b/test/functional/browse_controller_test.rb
new file mode 100644 (file)
index 0000000..81dbede
--- /dev/null
@@ -0,0 +1,77 @@
+require File.dirname(__FILE__) + '/../test_helper'
+require 'browse_controller'
+
+# Re-raise errors caught by the controller.
+class BrowseController; def rescue_action(e) raise e end; end
+
+  class BrowseControllerTest < Test::Unit::TestCase
+  api_fixtures
+  
+
+
+  def setup
+    @controller = BrowseController.new
+    @request    = ActionController::TestRequest.new
+    @response   = ActionController::TestResponse.new
+  end
+
+  def basic_authorization(user, pass)
+    @request.env["HTTP_AUTHORIZATION"] = "Basic %s" % Base64.encode64("#{user}:#{pass}")
+  end
+
+  def content(c)
+    @request.env["RAW_POST_DATA"] = c.to_s
+  end
+
+  # We need to load the home page, then activate the start rjs method
+  # and finally check that the new panel has loaded.
+  def test_start
+  
+  end
+  
+  # This should display the last 20 nodes that were edited.
+  def test_index
+    @nodes = Node.find(:all, :order => "timestamp DESC", :limit => 20)
+    assert @nodes.size <= 20
+    get :index
+    assert_response :success
+    assert_template "index"
+    # Now check that all 20 (or however many were returned) nodes are in the html
+    assert_select "h2", :text => "#{@nodes.size} Recently Changed Nodes", :count => 1
+    assert_select "ul[id='recently_changed'] li a", :count => @nodes.size
+    @nodes.each do |node|
+      name = node.tags_as_hash['name'].to_s
+      name = "(No name)" if name.length == 0
+      assert_select "ul[id='recently_changed'] li a[href=/browse/node/#{node.id}]", :text => "#{name} - #{node.id} (#{node.version})"
+    end
+  end
+  
+  # Test reading a relation
+  def test_read_relation
+    
+  end
+  
+  def test_read_relation_history
+    
+  end
+  
+  def test_read_way
+    
+  end
+  
+  def test_read_way_history
+    
+  end
+  
+  def test_read_node
+    
+  end
+  
+  def test_read_node_history
+    
+  end
+  
+  def test_read_changeset
+    
+  end
+end