Skip to content

Commit

Permalink
chg: Refactoring of IssueStatus, IssuePriority, TimeEntryActivity, Cu…
Browse files Browse the repository at this point in the history
…stomField, Version(Information)
  • Loading branch information
Sven Krzyzak committed May 14, 2010
1 parent a114815 commit cf0f76e
Show file tree
Hide file tree
Showing 48 changed files with 188 additions and 154 deletions.
8 changes: 4 additions & 4 deletions app/controllers/mylyn_connector/activities_controller.rb
Expand Up @@ -7,13 +7,13 @@ class MylynConnector::ActivitiesController < ApplicationController

skip_before_filter :verify_authenticity_token

helper MylynConnector::MylynHelper

def all
#since 0.9 IssuePriority exists
#TODO Is this perhabs project specific???
@activities = is09? ? TimeEntryActivity.shared.active : Enumeration::get_values('ACTI');
@activities = TimeEntryActivity.shared.active

respond_to do |format|
format.xml {render :xml => @activities, :template => 'mylyn_connector/activities/all.rxml'}
format.xml {render :layout => false}
end
end

Expand Down
4 changes: 3 additions & 1 deletion app/controllers/mylyn_connector/custom_fields_controller.rb
Expand Up @@ -6,11 +6,13 @@ class MylynConnector::CustomFieldsController < ApplicationController

skip_before_filter :verify_authenticity_token

helper MylynConnector::MylynHelper

def all
@custom_fields = CustomField.all

respond_to do |format|
format.xml {render :xml => @custom_fields, :template => 'mylyn_connector/custom_fields/all.rxml'}
format.xml {render :layout => false}
end
end

Expand Down
4 changes: 3 additions & 1 deletion app/controllers/mylyn_connector/information_controller.rb
Expand Up @@ -5,12 +5,14 @@ class MylynConnector::InformationController < ApplicationController
include MylynConnector::Rescue::ClassMethods

skip_before_filter :verify_authenticity_token

helper MylynConnector::MylynHelper

def version
@data = MylynConnector::Version.to_a

respond_to do |format|
format.xml {render :xml => @data, :template => 'mylyn_connector/information/version.rxml'}
format.xml {render :layout => false}
end
end
end
4 changes: 3 additions & 1 deletion app/controllers/mylyn_connector/issue_status_controller.rb
Expand Up @@ -6,11 +6,13 @@ class MylynConnector::IssueStatusController < ApplicationController

skip_before_filter :verify_authenticity_token

helper MylynConnector::MylynHelper

def all
@issue_status = IssueStatus.find(:all)

respond_to do |format|
format.xml {render :xml => @issue_status, :template => 'mylyn_connector/issue_status/all.rxml'}
format.xml {render :layout => false}
end
end
end
7 changes: 4 additions & 3 deletions app/controllers/mylyn_connector/priorities_controller.rb
Expand Up @@ -7,12 +7,13 @@ class MylynConnector::PrioritiesController < ApplicationController

skip_before_filter :verify_authenticity_token

helper MylynConnector::MylynHelper

def all
#since 0.9 IssuePriority exists
@priorities = is09? ? IssuePriority.all : Enumeration::get_values('IPRI');
@priorities = IssuePriority.shared.active;

respond_to do |format|
format.xml {render :xml => @priorities, :template => 'mylyn_connector/priorities/all.rxml'}
format.xml {render :layout => false}
end
end

Expand Down
4 changes: 4 additions & 0 deletions app/helpers/mylyn_connector/mylyn_helper.rb
Expand Up @@ -6,4 +6,8 @@ def integer_list id_based
id_based.to_s.strip
end

def api_version
MylynConnector::Version
end

end
@@ -1,5 +1,5 @@
xml.instruct! :xml, :encoding => "UTF-8"
xml.activities :xmlns => 'http://redmin-mylyncon.sf.net/schemas/WS-API-2.6' do
xml.activities :xmlns => 'http://redmin-mylyncon.sf.net/api', :api=>api_version do
@activities.each do |activity|
xml.activity :id => activity.id do
xml.name activity.name
Expand Down
@@ -1,5 +1,5 @@
xml.instruct! :xml, :encoding => "UTF-8"
xml.customFields :xmlns => 'http://redmin-mylyncon.sf.net/schemas/WS-API-2.6' do
xml.customFields:xmlns => 'http://redmin-mylyncon.sf.net/api', :api=>api_version do
@custom_fields.each do |field|
xml.customField :id => field.id do
xml.name field.name
Expand Down
@@ -1,5 +1,5 @@
xml.instruct! :xml, :encoding => "UTF-8"
xml.version :xmlns => 'http://redmin-mylyncon.sf.net/schemas/WS-API-2.6' do
xml.version :xmlns => 'http://redmin-mylyncon.sf.net/api', :api=>api_version do
xml.plugin(MylynConnector::Version,
:major => @data[0],
:minor => @data[1],
Expand Down
@@ -1,5 +1,5 @@
xml.instruct! :xml, :encoding => "UTF-8"
xml.issueStatuses :xmlns => 'http://redmin-mylyncon.sf.net/schemas/WS-API-2.6' do
xml.issueStatuses :xmlns => 'http://redmin-mylyncon.sf.net/api', :api=>api_version do
@issue_status.each do |status|
xml.issueStatus :id => status.id do
xml.name status.name
Expand Down
@@ -1,5 +1,5 @@
xml.instruct! :xml, :encoding => "UTF-8"
xml.priorities :xmlns => 'http://redmin-mylyncon.sf.net/schemas/WS-API-2.6' do
xml.priorities :xmlns => 'http://redmin-mylyncon.sf.net/api', :api=>api_version do
@priorities.each do |priority|
xml.priority :id => priority.id do
xml.name priority.name
Expand Down
6 changes: 3 additions & 3 deletions lib/mylyn_connector/version.rb
@@ -1,11 +1,11 @@
module MylynConnector
module Version
MAJOR = 2
MINOR = 6
TINY = 4
MINOR = 7
TINY = 0

# stable/trunk
BRANCH = 'stable'
BRANCH = 'trunk'

#Code from Redmine::Version
def self.revision
Expand Down
15 changes: 9 additions & 6 deletions test/functional/activities_controller_test.rb
Expand Up @@ -11,15 +11,18 @@ def setup
def test_all
get :all
assert_response :success
assert_template 'all.rxml'
assert_template 'all.xml.builder'

xmldoc = XML::Document.string @response.body
schema = read_schema 'activities'
schema = read_schema 'timeEntryActivities'
valid = xmldoc.validate_schema schema
assert valid , 'Ergenis passt nicht zum Schema ' + 'activities'
assert valid , 'Ergebnis passt nicht zum Schema ' + 'activities'

#0.8 3
#0.9 4
assert_tag :tag => 'activities', :children => {:count => 3..4}
acts = {:tag => 'activities', :children => {:count => 3}, :attributes => {:api => /^2.7.0/}}
act = {:tag => 'activity', :attributes => {:id => 10}, :parent => acts}
assert_tag :tag => 'name', :content => 'Development', :parent => act
assert_tag :tag => 'position', :content => '2', :parent => act
assert_tag :tag => 'default', :content => 'true', :parent => act

end
end
20 changes: 12 additions & 8 deletions test/functional/custom_fields_controller_test.rb
Expand Up @@ -12,31 +12,35 @@ def setup
def test_all
get :all
assert_response :success
assert_template 'all.rxml'
assert_template 'all.xml.builder'

xmldoc = XML::Document.string @response.body
schema = read_schema 'customFields'
valid = xmldoc.validate_schema schema
assert valid , 'Ergenis passt nicht zum Schema ' + 'customFields'
assert valid , 'Ergebnis passt nicht zum Schema ' + 'customFields'

cfl = {:tag => 'customfields', :children => {:count => 9}, :attributes => {:api => /^2.7.0/}}
cf = {:tag => 'customfield', :attributes => {:id => 1}, :parent => cfl}
assert_tag :tag => 'name', :content => 'Database', :parent => cf
assert_tag :tag => 'type', :content => 'IssueCustomField', :parent => cf
assert_tag :tag => 'fieldformat', :content => 'list', :parent => cf
assert_tag :tag => 'required', :content => 'false', :parent => cf
assert_tag :tag => 'filter', :content => 'true', :parent => cf

#Redmine0.8 5
#Redmine0.9 9
assert_tag :tag => 'customfields', :children => {:count => 5..9}
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'
assert_template 'all.xml.builder'

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}
assert_tag :tag => 'customfields', :children => {:count => 0}, :attributes => {:api => /^2.7.0/}
end
end
4 changes: 2 additions & 2 deletions test/functional/information_controller_test.rb
Expand Up @@ -10,10 +10,10 @@ def setup
def test_version
get :version
assert_response :success
assert_template 'version.rxml'
assert_template 'version.xml.builder'

xmldoc = XML::Document.string @response.body
schema = read_schema 'version'
schema = read_schema 'information'

valid = xmldoc.validate_schema schema
assert valid , 'Ergenis passt nicht zum Schema ' + 'version'
Expand Down
13 changes: 9 additions & 4 deletions test/functional/issue_status_controller_test.rb
Expand Up @@ -12,28 +12,33 @@ def setup
def test_all
get :all
assert_response :success
assert_template 'all.rxml'
assert_template 'all.xml.builder'

xmldoc = XML::Document.string @response.body
schema = read_schema 'issueStatus'
valid = xmldoc.validate_schema schema
assert valid , 'Ergenis passt nicht zum Schema ' + 'issueStatus'

assert_tag :tag => 'issuestatuses', :children => {:count => 6}
stats = {:tag => 'issuestatuses', :children => {:count => 6}, :attributes => {:api => /^2.7.0/}}
stat = {:tag => 'issuestatus', :attributes => {:id => 5}, :parent => stats}
assert_tag :tag => 'name', :content => 'Closed', :parent => stat
assert_tag :tag => 'closed', :content => 'true', :parent => stat
assert_tag :tag => 'default', :content => 'false', :parent => stat

end

def test_all_empty_is_valid
IssueStatus.delete_all

get :all
assert_response :success
assert_template 'all.rxml'
assert_template 'all.xml.builder'

xmldoc = XML::Document.string @response.body
schema = read_schema 'issueStatus'
valid = xmldoc.validate_schema schema
assert valid , 'Ergenis passt nicht zum Schema ' + 'issueStatus'

assert_tag :tag => 'issuestatuses', :children => {:count => 0}
assert_tag :tag => 'issuestatuses', :children => {:count => 0}, :attributes => {:api => /^2.7.0/}
end
end
22 changes: 11 additions & 11 deletions test/functional/priorities_controller_test.rb
Expand Up @@ -11,31 +11,31 @@ def setup
def test_all
get :all
assert_response :success
assert_template 'all.rxml'
assert_template 'all.xml.builder'

xmldoc = XML::Document.string @response.body
schema = read_schema 'priorities'
schema = read_schema 'issuePriorities'
valid = xmldoc.validate_schema schema
assert valid , 'Ergenis passt nicht zum Schema ' + 'priorities'

assert_tag :tag => 'priorities', :children => {:count => 5}
pris = {:tag => 'priorities', :children => {:count => 5}, :attributes => {:api => /^2.7.0/}}
pri = {:tag => 'priority', :attributes => {:id => 7}, :parent => pris}
assert_tag :tag => 'name', :content => 'Urgent', :parent => pri
assert_tag :tag => 'position', :content => '4', :parent => pri
assert_tag :tag => 'default', :content => 'false', :parent => pri

end

def test_all_empty_is_valid
#since 0.9 IssuePriority exists
if is09?
IssuePriority.delete_all
else
Enumeration.delete_all("opt='IPRI'")
end
IssuePriority.delete_all

get :all

xmldoc = XML::Document.string @response.body
schema = read_schema 'priorities'
schema = read_schema 'issuePriorities'
valid = xmldoc.validate_schema schema
assert valid , 'Ergenis passt nicht zum Schema ' + 'priorities'

assert_tag :tag => 'priorities', :children => {:count => 0}
assert_tag :tag => 'priorities', :children => {:count => 0}, :attributes => {:api => /^2.7.0/}
end
end
19 changes: 0 additions & 19 deletions test/schema/activities.xsd

This file was deleted.

9 changes: 5 additions & 4 deletions test/schema/customFields.xsd
@@ -1,18 +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"
xmlns:tns="http://redmin-mylyncon.sf.net/api"
targetNamespace="http://redmin-mylyncon.sf.net/api"
elementFormDefault="qualified" >

<xsd:include schemaLocation="types/customField.xsd" />
<xsd:include schemaLocation="types/versionstring.xsd" />

<xsd:element name="customFields"
xmlns="http://redmine-mylyn.sf.net/schemas/WS-API-2.6/customfields">
<xsd:element name="customFields" xmlns="http://redmin-mylyncon.sf.net/api">

<xsd:complexType>
<xsd:sequence >
<xsd:element name="customField" type="tns:customField" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
<xsd:attribute name="api" type="tns:versionstring" use="required" />
</xsd:complexType>
</xsd:element>

Expand Down
17 changes: 6 additions & 11 deletions test/schema/version.xsd → test/schema/information.xsd
@@ -1,12 +1,13 @@
<?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"
xmlns:tns="http://redmin-mylyncon.sf.net/api"
targetNamespace="http://redmin-mylyncon.sf.net/api"
elementFormDefault="qualified" >

<xsd:element name="version"
xmlns="http://redmine-mylyn.sf.net/schemas/WS-API-2.6/version">
<xsd:include schemaLocation="types/versionstring.xsd" />

<xsd:element name="version" xmlns="http://redmin-mylyncon.sf.net/api">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="plugin">
Expand All @@ -23,13 +24,7 @@
<xsd:element name="redmine" type="tns:versionstring" />
<xsd:element name="rails" type="tns:versionstring" />
</xsd:sequence>
<xsd:attribute name="api" type="tns:versionstring" use="required" />
</xsd:complexType>
</xsd:element>

<xsd:simpleType name="versionstring">
<xsd:restriction base="xsd:string">
<!-- Version-String example: 2.5.1.trunk.255 -->
<xsd:pattern value="\d+\.\d+\.\d+(\.(stable|trunk|branch|devel))?(\.\d+)?" />
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
4 changes: 2 additions & 2 deletions test/schema/issue.xsd
@@ -1,7 +1,7 @@
<?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"
xmlns:tns="http://redmin-mylyncon.sf.net/api"
targetNamespace="http://redmin-mylyncon.sf.net/api"
elementFormDefault="qualified" >

<xsd:include schemaLocation="types/issue.xsd" />
Expand Down

0 comments on commit cf0f76e

Please sign in to comment.