Skip to content
Browse files

add: Users

  • Loading branch information...
1 parent 1f3bb34 commit e4f35a36f32c05088a9e84937905a94254538b26 Sven Krzyzak committed
View
20 app/controllers/mylyn_connector/users_controller.rb
@@ -0,0 +1,20 @@
+require File.dirname(__FILE__) + '/../../../lib/mylyn_connector'
+
+class MylynConnector::UsersController < ApplicationController
+ unloadable
+ include MylynConnector::Rescue::ClassMethods
+ include MylynConnector::Version::ClassMethods
+
+ skip_before_filter :verify_authenticity_token
+
+ helper MylynConnector::MylynHelper
+
+ def all
+ @users = User.find(:all)
+
+ respond_to do |format|
+ format.xml {render :layout => false}
+ end
+ end
+
+end
View
12 app/views/mylyn_connector/users/all.xml.builder
@@ -0,0 +1,12 @@
+xml.instruct! :xml, :encoding => "UTF-8"
+xml.users :xmlns => 'http://redmin-mylyncon.sf.net/api', :api=>api_version do
+ @users.each do |user|
+ xml.user :id => user.id do
+ xml.name user.name
+ xml.login user.login
+ xml.firstname user.firstname
+ xml.lastname user.lastname
+ xml.mail user.mail
+ end
+ end
+end
View
1 config/routes.rb
@@ -4,6 +4,7 @@
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/users", :controller => "MylynConnector::Users", :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
31 test/functional/users_controller_test.rb
@@ -0,0 +1,31 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class MylynConnector::UsersControllerTest < MylynConnector::ControllerTest
+ fixtures :users
+
+ def setup
+ super
+ @controller = MylynConnector::UsersController.new
+ end
+
+ def test_all
+ get :all
+ assert_response :success
+ assert_template 'all.xml.builder'
+
+ xmldoc = XML::Document.string @response.body
+ schema = read_schema 'users'
+ valid = xmldoc.validate_schema schema
+ assert valid , 'Ergebnis passt nicht zum Schema ' + 'users'
+
+ users = {:tag => 'users', :children => {:count => 9}, :attributes => {:api => /^2.7.0/}}
+ user = {:tag => 'user', :attributes => {:id => 5}, :parent => users}
+# assert_tag :tag => 'name', :content => 'Dave2 Lopper2', :parent => user
+ assert_tag :tag => 'login', :content => 'dlopper2', :parent => user
+ assert_tag :tag => 'firstname', :content => 'Dave2', :parent => user
+ assert_tag :tag => 'lastname', :content => 'Lopper2', :parent => user
+ assert_tag :tag => 'mail', :content => 'dlopper2@somenet.foo', :parent => user
+
+ end
+
+end
View
24 test/schema/types/user.xsd
@@ -0,0 +1,24 @@
+<?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="property.xsd" />
+
+ <xsd:complexType name="user">
+ <xsd:complexContent>
+ <xsd:extension base="tns:property">
+ <xsd:sequence>
+ <xsd:element name="login" type="xsd:string" />
+ <xsd:element name="firstname" type="xsd:string" />
+ <xsd:element name="lastname" type="xsd:string" />
+ <!-- TODO add type email -->
+ <xsd:element name="mail" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+</xsd:schema>
View
19 test/schema/users.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/user.xsd" />
+ <xsd:include schemaLocation="types/versionstring.xsd" />
+
+ <xsd:element name="users" xmlns="http://redmin-mylyncon.sf.net/api" >
+ <xsd:complexType>
+ <xsd:sequence >
+ <xsd:element name="user" type="tns:user" 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 e4f35a3

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