Browse files

chg: issue (issue list)

  • Loading branch information...
1 parent 718b9b4 commit 4ff272a75346c0af8676d4d4ced0d751e96f698c Sven Krzyzak committed May 25, 2010
View
17 app/controllers/mylyn_connector/issues_controller.rb
@@ -43,7 +43,6 @@ def query
end
def updated_since
-
time = Time.at(params[:unixtime].to_i)
issues = params[:issues].split(',')
@@ -63,6 +62,22 @@ def updated_since
end
end
+ def list
+ issues = params[:issues].split(',')
+ issues.collect! { |x| x.to_i }
+ issues.uniq!
+ issues.compact!
+
+ @issues = Issue.find(
+ :all,
+ :joins => ["join #{Project.table_name} on project_id=#{Project.table_name}.id"],
+ :conditions => ["#{Issue.table_name}.id in (?) and " << Project.visible_by, issues]
+ )
+ respond_to do |format|
+ format.xml {render :layout => false}
+ end
+ end
+
private
def authorize
View
2 app/views/mylyn_connector/issues/_issue.rxml
@@ -1,4 +1,4 @@
-xml.issue(:xmlns => 'http://redmin-mylyncon.sf.net/api', :api=>api_version, :id => issue.id, :editAllowed => edit_allowed?(issue) ) do
+xml.issue({:id => issue.id, :editAllowed => edit_allowed?(issue)}.merge(attr||={}) ) do
#Ticket
xml.subject issue.subject
View
4 app/views/mylyn_connector/issues/index.rxml → ...s/mylyn_connector/issues/list.xml.builder
@@ -1,4 +1,4 @@
xml.instruct! :xml, :encoding => "UTF-8"
-xml.issues :xmlns => 'http://redmin-mylyncon.sf.net/schemas/WS-API-2.6' do
+xml.issues :xmlns => 'http://redmin-mylyncon.sf.net/api', :api=>api_version do
xml << render(:partial => 'issue.rxml', :collection => @issues) unless @issues.empty?
-end
+end
View
2 app/views/mylyn_connector/issues/show.xml.builder
@@ -1,2 +1,2 @@
xml.instruct! :xml, :encoding => "UTF-8"
-xml << render(:partial => 'issue.rxml', :locals => {:issue=>@issue} )
+xml << render(:partial => 'issue.rxml', :locals => {:issue=>@issue, :attr => {:xmlns => 'http://redmin-mylyncon.sf.net/api', :api=>api_version}} )
View
3 config/routes.rb
@@ -19,6 +19,7 @@
# map.connect "mylyn/:project_id/search", :controller => "MylynConnector::Issues", :action => "query"
# map.connect "mylyn/search", :controller => "MylynConnector::Issues", :action => "query"
- map.connect "mylyn/:project_id/updatedsince", :controller => "MylynConnector::Issues", :action => "updated_since"
map.connect "mylyn/issue/:id", :controller => "MylynConnector::Issues", :action => "show", :conditions => {:method => :get}
+ map.connect "mylyn/issues/updatedsince", :controller => "MylynConnector::Issues", :action => "updated_since", :conditions => {:method => :get}
+ map.connect "mylyn/issues/list", :controller => "MylynConnector::Issues", :action => "list", :conditions => {:method => :get}
end
View
24 test/functional/issues_controller_test.rb
@@ -145,6 +145,25 @@ def test_updated_since
assert_tag :tag => 'updatedissues', :content => '1 8', :attributes => {:api => /^2.7.0/}
end
+ def test_list
+ get :list, :issues => '1, 6 , 8 , 17,20'
+
+ assert_response :success
+ assert_template 'list.xml.builder'
+
+ #puts @response.body
+ xmldoc = XML::Document.string @response.body
+ schema = read_schema 'issues'
+ valid = xmldoc.validate_schema schema
+ assert valid , 'Ergenis passt nicht zum Schema ' + 'issues'
+
+ lst = {:tag => 'issues', :children => {:count => 2}, :attributes => {:api => /^2.7.0/}}
+ assert_tag lst
+ assert_tag :tag => 'issue', :attributes => {:id => 1, :editallowed => 'false'}, :parent => lst
+ assert_tag :tag => 'issue', :attributes => {:id => 8, :editallowed => 'false'}, :parent => lst
+
+ end
+
def test_show_404
get :show, :id => 99
assert_response 404
@@ -221,10 +240,5 @@ def test_show_404
# assert_tag :tag => 'issue', :attributes => {:id => 4}
# assert_tag :tag => 'issue', :attributes => {:id => 6}
# end
-#
-# def test_query_non_exists
-# get :query, :project_id => 1, :query_id => 99
-# assert_response 404
-# end
end
View
3 test/schema/issues.xsd
@@ -5,13 +5,14 @@
elementFormDefault="qualified" >
<xsd:include schemaLocation="types/issue.xsd" />
+ <xsd:include schemaLocation="types/versionstring.xsd" />
<xsd:element name="issues" xmlns="http://redmin-mylyncon.sf.net/api">
<xsd:complexType>
<xsd:sequence >
<xsd:element name="issue" type="tns:issue" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
- <xsd:attribute name="newAllowed" type="xsd:boolean" use="required"/>
+ <xsd:attribute name="api" type="tns:versionstring" use="required" />
</xsd:complexType>
</xsd:element>
View
1 test/schema/projects.xsd
@@ -5,6 +5,7 @@
elementFormDefault="qualified" >
<xsd:include schemaLocation="types/project.xsd" />
+ <xsd:include schemaLocation="types/versionstring.xsd" />
<xsd:element name="projects" xmlns="http://redmin-mylyncon.sf.net/api">
<xsd:complexType>

0 comments on commit 4ff272a

Please sign in to comment.