Permalink
Browse files

iadd: CrossProjectQueries

git-svn-id: file:///home/sven/rmc_backup/svn_neu/trunk@293 738a3cfe-f54d-0410-852a-ebac1faf349d
  • Loading branch information...
1 parent 3535ecc commit 378a670a674d86a0b800267338f43cfd395ffe85 sven-k committed Oct 19, 2009
View
14 app/controllers/mylyn_connector/issues_controller.rb
@@ -6,7 +6,7 @@ class MylynConnector::IssuesController < ApplicationController
before_filter :find_issue, :only => [:show]
before_filter :find_project
- before_filter :authorize
+ before_filter :authorize, :except => [:query]
helper MylynConnector::WatchersHelper
@@ -22,8 +22,8 @@ def query
if !query.blank? && query.valid?
begin
- #workaround: sometimes (why ?!), query dosn't contains the correct project
- condition = ARCondition.new(["issues.project_id = ?", @project.id])
+ condition = ARCondition.new
+ condition << ["issues.project_id = ?", @project.id] if @project
condition << query.statement
@issues = Issue.find :all,
@@ -65,9 +65,9 @@ def find_issue
end
def find_project
- if params[:project_id].blank?
+ if @issue
@project = @issue.project
- else
+ elsif !params[:project_id].blank?
begin
@project = Project.find(params[:project_id])
rescue ActiveRecord::RecordNotFound
@@ -82,13 +82,13 @@ def retrieve_query query_id, query_string
begin
# Code form Issue_helper
visible = ARCondition.new(["is_public = ? OR user_id = ?", true, User.current.id])
- visible << (["project_id IS NULL OR project_id = ?", @project.id])
+ visible << (["project_id IS NULL OR project_id = ?", @project.id]) if @project
query = Query.find(query_id, :conditions => visible.conditions)
rescue
query = Query.new
end
- query.project = @project
+ query.project = @project if @project
else
querydecoder = MylynConnector::QueryStringDecoder.new(query_string)
query = querydecoder.query
View
4 app/views/mylyn_connector/issues/_issue.rxml
@@ -41,7 +41,7 @@ xml.issue(:xmlns => 'http://redmin-mylyncon.sf.net/schemas/WS-API-2.6', :id => i
xml.author journal.user==nil ? "Anonymous" : journal.user.name
xml.createdOn journal.created_on.xmlschema, :unixtime => journal.created_on.to_i
xml.notes journal.notes
- xml.editableByUser journal.editable_by?(User.current)
+ xml.editableByUser journal.editable_by?(User.current) ? true : false
end
}
}
@@ -66,7 +66,7 @@ xml.issue(:xmlns => 'http://redmin-mylyncon.sf.net/schemas/WS-API-2.6', :id => i
xml.issueFromId relation.issue_from_id
xml.issueToId relation.issue_to_id
xml.type relation.relation_type
- xml.delay relation.delay
+ xml.delay relation.delay if relation.delay && relation.delay >0
end
}
}
View
1 config/routes.rb
@@ -7,5 +7,6 @@
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/search", :controller => "MylynConnector::Issues", :action => "query"
map.connect "mylyn/:project_id/updatedsince", :controller => "MylynConnector::Issues", :action => "updated_since"
end
View
2 release-note.txt
@@ -2,7 +2,7 @@ Version 2.6
Startdate + Duedate
Watchers
TimeTracking / Spenttime
- TODO: CrossProjectQueries
+ CrossProjectQueries
Version 2.5.2
Bugfix: Detailed Status-Header for server errors
View
1 routes.rb
@@ -6,4 +6,5 @@
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/search", :controller => "MylynConnector::Issues", :action => "query"
connect "mylyn/:project_id/updatedsince", :controller => "MylynConnector::Issues", :action => "updated_since"
View
40 test/functional/issues_controller_test.rb
@@ -130,6 +130,46 @@ def test_query_by_string
assert valid , 'Ergenis passt nicht zum Schema ' + 'issues'
assert_tag :tag => 'issues', :children => {:count => 2}
+ assert_tag :tag => 'issue', :attributes => {:id => 3}
+ assert_tag :tag => 'issue', :attributes => {:id => 7}
+ end
+
+ def test_cross_query_by_string
+ post :query, :query_string => 'set_filter=1&fields[]=tracker_id&operators[tracker_id]=%3D&values[tracker_id][]=1&fields[]=priority_id&operators[priority_id]=%3D&values[priority_id][]=4'
+
+ assert_response :success
+ assert_template 'index.rxml'
+
+ xmldoc = XML::Document.string @response.body
+ schema = read_schema 'issues'
+ valid = xmldoc.validate_schema schema
+ assert valid , 'Ergenis passt nicht zum Schema ' + 'issues'
+
+ #redmine 0.8:
+ #redmine 0.9: 1,3,5
+ assert_tag :tag => 'issues', :children => {:count => 3}
+ assert_tag :tag => 'issue', :attributes => {:id => 1}
+ assert_tag :tag => 'issue', :attributes => {:id => 3}
+ assert_tag :tag => 'issue', :attributes => {:id => 5}
+ end
+
+ def test_cross_query_by_string_authenticated
+ @request.session[:user_id] = 2
+ post :query, :query_string => 'set_filter=1&fields[]=tracker_id&operators[tracker_id]=%3D&values[tracker_id][]=1&fields[]=priority_id&operators[priority_id]=%3D&values[priority_id][]=4'
+
+ assert_response :success
+ assert_template 'index.rxml'
+
+ xmldoc = XML::Document.string @response.body
+ schema = read_schema 'issues'
+ valid = xmldoc.validate_schema schema
+ assert valid , 'Ergenis passt nicht zum Schema ' + 'issues'
+
+ assert_tag :tag => 'issue', :attributes => {:id => 1}
+ assert_tag :tag => 'issue', :attributes => {:id => 3}
+ assert_tag :tag => 'issue', :attributes => {:id => 5}
+ assert_tag :tag => 'issue', :attributes => {:id => 4}
+ assert_tag :tag => 'issue', :attributes => {:id => 6}
end
def test_query_non_exists
View
2 test/functional/projects_controller_test.rb
@@ -5,7 +5,7 @@ class MylynConnector::ProjectsControllerTest < MylynConnector::ControllerTest
class << self
def fixtures(*table_names)
- #TODO since 0.9 IssuePriority exists
+ #TODO since 0.9 MemberRole exists
table_names.push(:member_roles) if Object.const_defined?(:MemberRole)
super(table_names)
View
2 test/schema/types/issueRelation.xsd
@@ -19,7 +19,7 @@
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
- <xsd:element name="delay" type="xsd:integer" />
+ <xsd:element name="delay" type="xsd:integer" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="id" type="xsd:integer" use="required" />
</xsd:complexType>

0 comments on commit 378a670

Please sign in to comment.