Skip to content
Browse files

add: Version

  • Loading branch information...
1 parent eae4183 commit 1f3bb341a1ea9f92731a2c9c81b55ba558eaac62 Sven Krzyzak committed
View
18 app/controllers/mylyn_connector/versions_controller.rb
@@ -0,0 +1,18 @@
+require File.dirname(__FILE__) + '/../../../lib/mylyn_connector'
+
+class MylynConnector::VersionsController < ApplicationController
+ unloadable
+ include MylynConnector::Rescue::ClassMethods
+
+ skip_before_filter :verify_authenticity_token
+
+ helper MylynConnector::MylynHelper
+
+ def all
+ @versions = Version.find(:all)
+
+ respond_to do |format|
+ format.xml {render :layout => false}
+ end
+ end
+end
View
9 app/views/mylyn_connector/versions/all.xml.builder
@@ -0,0 +1,9 @@
+xml.instruct! :xml, :encoding => "UTF-8"
+xml.versions :xmlns => 'http://redmin-mylyncon.sf.net/api', :api=>api_version do
+ @versions.each do |version|
+ xml.version :id => version.id do
+ xml.name version.name
+ xml.status version.status
+ end
+ end
+end
View
1 config/routes.rb
@@ -3,6 +3,7 @@
map.connect "mylyn/projects", :controller => "MylynConnector::Projects", :action => "all", :conditions => {:method => :get}
map.connect "mylyn/priorities", :controller => "MylynConnector::Priorities", :action => "all", :conditions => {:method => :get}
map.connect "mylyn/trackers", :controller => "MylynConnector::Trackers", :action => "all", :conditions => {:method => :get}
+ map.connect "mylyn/versions", :controller => "MylynConnector::Versions", :action => "all", :conditions => {:method => :get}
map.connect "mylyn/activities", :controller => "MylynConnector::Activities", :action => "all", :conditions => {:method => :get}
map.connect "mylyn/issuestatus", :controller => "MylynConnector::IssueStatus", :action => "all", :conditions => {:method => :get}
map.connect "mylyn/issuecategories", :controller => "MylynConnector::IssueCategories", :action => "all", :conditions => {:method => :get}
View
2 test/functional/trackers_controller_test.rb
@@ -16,7 +16,7 @@ def test_all
xmldoc = XML::Document.string @response.body
schema = read_schema 'trackers'
valid = xmldoc.validate_schema schema
- assert valid , 'Ergebnis passt nicht zum Schema ' + 'priorities'
+ assert valid , 'Ergebnis passt nicht zum Schema ' + 'trackers'
trs = {:tag => 'trackers', :children => {:count => 3}, :attributes => {:api => /^2.7.0/}}
tr = {:tag => 'tracker', :attributes => {:id => 3}, :parent => trs}
View
40 test/functional/versions_controller_test.rb
@@ -0,0 +1,40 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class MylynConnector::VersionsControllerTest < MylynConnector::ControllerTest
+ fixtures :versions
+
+ def setup
+ super
+ @controller = MylynConnector::VersionsController.new
+ end
+
+ def test_all
+ get :all
+ assert_response :success
+ assert_template 'all.xml.builder'
+
+ xmldoc = XML::Document.string @response.body
+ schema = read_schema 'versions'
+ valid = xmldoc.validate_schema schema
+ assert valid , 'Ergebnis passt nicht zum Schema ' + 'versions'
+
+ vers = {:tag => 'versions', :children => {:count => 7}, :attributes => {:api => /^2.7.0/}}
+ ver = {:tag => 'version', :attributes => {:id => 4}, :parent => vers}
+ assert_tag :tag => 'name', :content => '2.0', :parent => ver
+ assert_tag :tag => 'status', :content => 'open', :parent => ver
+
+ end
+
+ def test_all_empty_is_valid
+ Version.delete_all
+
+ get :all
+
+ xmldoc = XML::Document.string @response.body
+ schema = read_schema 'versions'
+ valid = xmldoc.validate_schema schema
+ assert valid , 'Ergebnis passt nicht zum Schema ' + 'versions'
+
+ assert_tag :tag => 'versions', :children => {:count => 0}, :attributes => {:api => /^2.7.0/}
+ end
+end
View
11 test/schema/types/version.xsd
@@ -11,10 +11,17 @@
<xsd:complexContent>
<xsd:extension base="tns:property">
<xsd:sequence>
- <xsd:element name="open" type="xsd:boolean" />
+ <xsd:element name="status">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="open" />
+ <xsd:enumeration value="closed" />
+ <xsd:enumeration value="locked" />
+ </xsd:restriction>
+ </xsd:simpleType>
+ </xsd:element>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
-
</xsd:schema>
View
19 test/schema/versions.xsd
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://redmin-mylyncon.sf.net/api"
+ targetNamespace="http://redmin-mylyncon.sf.net/api"
+ elementFormDefault="qualified" >
+
+ <xsd:include schemaLocation="types/version.xsd" />
+ <xsd:include schemaLocation="types/versionstring.xsd" />
+
+ <xsd:element name="versions" xmlns="http://redmin-mylyncon.sf.net/api" >
+ <xsd:complexType>
+ <xsd:sequence >
+ <xsd:element name="version" type="tns:version" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="api" type="tns:versionstring" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+
+</xsd:schema>

0 comments on commit 1f3bb34

Please sign in to comment.
Something went wrong with that request. Please try again.