Browse files

bugfix: missing WatchersHelper:

add: CustomFieldsController;


git-svn-id: file:///home/sven/rmc_backup/svn_neu/trunk@285 738a3cfe-f54d-0410-852a-ebac1faf349d
  • Loading branch information...
1 parent 24cacf6 commit 0184566ba90a1c8135e1344337a4577e9e4d137c sven-k committed Oct 10, 2009
View
15 app/controllers/mylyn_connector/custom_fields_controller.rb
@@ -0,0 +1,15 @@
+require File.dirname(__FILE__) + '/../../../lib/mylyn_connector'
+
+class MylynConnector::CustomFieldsController < ApplicationController
+ unloadable
+# include MylynConnector::Rescue::ClassMethods
+
+ def all
+ @custom_fields = CustomField.all
+
+ respond_to do |format|
+ format.xml {render :xml => @custom_fields, :template => 'mylyn_connector/custom_fields/all.rxml'}
+ end
+ end
+
+end
View
2 app/controllers/mylyn_connector/projects_controller.rb
@@ -6,6 +6,8 @@ class MylynConnector::ProjectsController < ApplicationController
before_filter :find_project, :only => [:get]
+ helper MylynConnector::MylynHelper
+
def all
@projects = Project.find(:all,
:joins => :enabled_modules,
View
9 app/helpers/mylyn_connector/mylyn_helper.rb
@@ -0,0 +1,9 @@
+
+module MylynConnector::MylynHelper
+
+ def integer_list id_based
+ id_based.collect! { |i| i.id.to_s + " "}
+ id_based.to_s.strip
+ end
+
+end
View
5 app/helpers/mylyn_connector/projects_helper.rb
@@ -44,9 +44,4 @@ def get_queries project
:conditions => visible.conditions)
end
- def integer_list id_based
- id_based.collect! { |i| i.id.to_s + " "}
- id_based.to_s.strip
- end
-
end
View
13 app/helpers/mylyn_connector/watchers_helper.rb
@@ -0,0 +1,13 @@
+
+module MylynConnector::WatchersHelper
+ def watched?(issue)
+ return false unless User.current.logged?
+ return issue.watched_by?(User.current)
+ end
+
+
+ def watchers(issue)
+ issue.watcher_users.collect {|u| u.id }.join(" ")
+ end
+
+end
View
23 app/views/mylyn_connector/custom_fields/all.rxml
@@ -0,0 +1,23 @@
+xml.instruct! :xml, :encoding => "UTF-8"
+xml.customFields :xmlns => 'http://redmin-mylyncon.sf.net/schemas/WS-API-2.6' do
+ @custom_fields.each do |field|
+ xml.customField :id => field.id do
+ xml.name field.name
+ xml.type field.type
+ xml.fieldFormat field.field_format
+ xml.minLength field.min_length
+ xml.maxLength field.max_length
+ xml.regexp field.regexp
+ if field.possible_values
+ xml.possibleValues {
+ field.possible_values.each {|value|xml.possibleValue value}
+ }
+ else
+ xml.possibleValues
+ end
+ xml.defaultValue field.default_value
+ xml.required field.is_required
+ xml.filter field.is_filter
+ 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/issuestatus", :controller => "MylynConnector::IssueStatus", :action => "all", :conditions => {:method => :get}
+ map.connect "mylyn/customfields", :controller => "MylynConnector::CustomFields", :action => "all", :conditions => {:method => :get}
map.connect "mylyn/version", :controller => "MylynConnector::Information", :action => "version", :conditions => {:method => :get}
map.connect "mylyn/:project_id/search", :controller => "MylynConnector::Issues", :action => "query"
map.connect "mylyn/:project_id/updatedsince", :controller => "MylynConnector::Issues", :action => "updated_since"
View
1 routes.rb
@@ -2,6 +2,7 @@
connect "mylyn/projects", :controller => "MylynConnector::Projects", :action => "all", :conditions => {:method => :get}
connect "mylyn/priorities", :controller => "MylynConnector::Priorities", :action => "all", :conditions => {:method => :get}
connect "mylyn/issuestatus", :controller => "MylynConnector::IssueStatus", :action => "all", :conditions => {:method => :get}
+connect "mylyn/customfields", :controller => "MylynConnector::CustomFields", :action => "all", :conditions => {:method => :get}
connect "mylyn/version", :controller => "MylynConnector::Information", :action => "version", :conditions => {:method => :get}
connect "mylyn/:project_id/search", :controller => "MylynConnector::Issues", :action => "query"
connect "mylyn/:project_id/updatedsince", :controller => "MylynConnector::Issues", :action => "updated_since"
View
40 test/functional/custom_fields_controller_test.rb
@@ -0,0 +1,40 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class MylynConnector::CustomFieldsControllerTest < MylynConnector::ControllerTest
+
+ fixtures :custom_fields
+
+ def setup
+ super
+ @controller = MylynConnector::CustomFieldsController.new
+ end
+
+ def test_all
+ get :all
+ assert_response :success
+ assert_template 'all.rxml'
+
+ xmldoc = XML::Document.string @response.body
+ schema = read_schema 'customFields'
+ valid = xmldoc.validate_schema schema
+ assert valid , 'Ergenis passt nicht zum Schema ' + 'customFields'
+
+ assert_tag :tag => 'customfields', :children => {:count => 5}
+ assert_tag :tag => 'customfield', :attributes => {:id => 1}, :children => {:only => {:tag => 'name', :content => 'Database', :sibling => {:tag => 'fieldformat', :content => 'list', :sibling => {:tag => 'trackers', :content => '1', :sibling => {:tag => 'required', :content => 'false'}, :sibling => {:tag => 'filter', :content => 'true'}}}}}
+ end
+
+ def test_all_empty_is_valid
+ CustomField.delete_all
+
+ get :all
+ assert_response :success
+ assert_template 'all.rxml'
+
+ xmldoc = XML::Document.string @response.body
+ schema = read_schema 'customFields'
+ valid = xmldoc.validate_schema schema
+ assert valid , 'Ergenis passt nicht zum Schema ' + 'customFields'
+
+ assert_tag :tag => 'customfields', :children => {:count => 0}
+ end
+end
View
19 test/schema/customFields.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/schemas/WS-API-2.6"
+ targetNamespace="http://redmin-mylyncon.sf.net/schemas/WS-API-2.6"
+ elementFormDefault="qualified" >
+
+ <xsd:include schemaLocation="types/customField.xsd" />
+
+ <xsd:element name="customFields"
+ xmlns="http://redmine-mylyn.sf.net/schemas/WS-API-2.6/customfields">
+
+ <xsd:complexType>
+ <xsd:sequence >
+ <xsd:element name="customField" type="tns:customField" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+</xsd:schema>
View
46 test/schema/types/customField.xsd
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://redmin-mylyncon.sf.net/schemas/WS-API-2.6"
+ targetNamespace="http://redmin-mylyncon.sf.net/schemas/WS-API-2.6"
+ elementFormDefault="qualified" >
+
+ <xsd:include schemaLocation="property.xsd" />
+
+ <xsd:complexType name="customField">
+ <xsd:complexContent>
+ <xsd:extension base="tns:property">
+ <xsd:sequence>
+ <xsd:element name="type" type="xsd:string" />
+ <xsd:element name="fieldFormat" >
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="string" />
+ <xsd:enumeration value="text" />
+ <xsd:enumeration value="int" />
+ <xsd:enumeration value="float" />
+ <xsd:enumeration value="list" />
+ <xsd:enumeration value="date" />
+ <xsd:enumeration value="bool" />
+ </xsd:restriction>
+ </xsd:simpleType>
+ </xsd:element>
+ <xsd:element name="minLength" type="xsd:integer" />
+ <xsd:element name="maxLength" type="xsd:integer" />
+ <xsd:element name="regexp" type="xsd:string" />
+ <xsd:element name="possibleValues" >
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="possibleValue" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="defaultValue" type="xsd:string" />
+ <xsd:element name="required" type="xsd:boolean" />
+ <xsd:element name="filter" type="xsd:boolean" />
+ </xsd:sequence>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+</xsd:schema>

0 comments on commit 0184566

Please sign in to comment.