Author: assaf
Date: Thu Jun 5 16:31:16 2008
New Revision: 663781
URL: http://svn.apache.org/viewvc?rev=663781&view=rev
Log:
Fix: it is now possible to delegate to 'anyone'.
Fix: Person.identify raises exception if person not found.
Removed:
ode/sandbox/singleshot/app/controllers/owners_controller.rb
Modified:
ode/sandbox/singleshot/app/helpers/task_helper.rb
ode/sandbox/singleshot/app/models/task.rb
ode/sandbox/singleshot/app/views/tasks/show.html.erb
ode/sandbox/singleshot/public/stylesheets/default.css
ode/sandbox/singleshot/spec/models/helper.rb
ode/sandbox/singleshot/spec/models/stakeholder_spec.rb
ode/sandbox/singleshot/spec/models/task_spec.rb
Modified: ode/sandbox/singleshot/app/helpers/task_helper.rb
URL:
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/helpers/task_helper.rb?rev=663781&r1=663780&r2=663781&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/helpers/task_helper.rb (original)
+++ ode/sandbox/singleshot/app/helpers/task_helper.rb Thu Jun 5 16:31:16 2008
@@ -2,7 +2,7 @@
def quick_actions(task)
[ task.admin?(authenticated) && button_to('Manage', edit_task_url(task),
:method=>:get, :title=>'Manage this task'),
- task.can_claim?(authenticated) && button_to('Claim', task_url(task,
'task[owner]'=>authenticated.identity),
+ task.can_claim?(authenticated) && button_to('Claim', task_url(task,
'task[owner]'=>authenticated),
:method=>:put, :title=>'Claim task')
].select { |action| action }.join(' ')
end
@@ -38,7 +38,7 @@
unless others.empty?
actions << form_tag(task_url(task), :method=>:put,
:class=>'button-to') +
'<select name="task[owner]"><option disabled>Select owner
...</option>' +
- options_for_select(others.map { |person| [person.fullname,
person.identity] }.sort) +
+ options_for_select(others.map { |person| [person.fullname,
person.to_param] }.sort) +
'<option value="">Anyone</option></select><input type="submit"
value="Delegate"></form>'
end
end
Modified: ode/sandbox/singleshot/app/models/task.rb
URL:
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/models/task.rb?rev=663781&r1=663780&r2=663781&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/models/task.rb (original)
+++ ode/sandbox/singleshot/app/models/task.rb Thu Jun 5 16:31:16 2008
@@ -97,7 +97,7 @@
#task.errors.add :status, "#{task.owner.fullname} is not allowed to
claim this task." unless
# task.potential_owners.empty? || task.potential_owner?(task.owner) ||
task.admin?(task.owner)
when 'suspended'
- task.errors.add :status, 'You are not allowed to suspend this task.'
unless task.admin?(task.modified_by)
+ task.errors.add :status, 'You are not allowed to suspend this task.'
unless task.modified_by && task.admin?(task.modified_by)
when 'completed'
task.errors.add :status, 'Cannot change to completed from any status but
active.' unless from =='active'
task.errors.add :status, 'Only owner can complete task.' unless
task.owner && task.modified_by == task.owner && !task.owner_changed?
@@ -157,7 +157,7 @@
# parameters are passed as last argument or returned from the block.
def render_url(perform, params = {})
url = perform ? perform_url : details_url
- return url unless integrated_ui
+ return url unless integrated_ui && url
params = yield if block_given?
uri = URI(url)
uri.query = CGI.parse(uri.query || '').update(params).to_query
@@ -213,7 +213,7 @@
define_method("#{role}?") { |identity| in_role?(role, identity) }
define_method "#{role}=" do |identity|
old_value = in_role(role)
- new_value = set_role(role, identity)
+ new_value = set_role(role, identity.blank? ? nil : identity)
changed_attributes[role] = old_value unless
changed_attributes.has_key?(role) || old_value == new_value
end
define_method("#{role}_changed?") { attribute_changed?(role) }
@@ -273,7 +273,7 @@
end
task.errors.add :creator, 'Cannot change creator.' if
task.creator_changed? && ![nil, 'reserved'].include?(task.status_was)
task.errors.add :owner, "#{task.owner.fullname} is on the excluded owners
list and cannot be owner of this task." if
- task.excluded_owner?(task.owner)
+ task.owner && task.excluded_owner?(task.owner)
to, from = task.owner_change
if task.potential_owners.empty?
# With no potential owners, task must have a set owner.
Modified: ode/sandbox/singleshot/app/views/tasks/show.html.erb
URL:
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/views/tasks/show.html.erb?rev=663781&r1=663780&r2=663781&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/views/tasks/show.html.erb (original)
+++ ode/sandbox/singleshot/app/views/tasks/show.html.erb Thu Jun 5 16:31:16
2008
@@ -1,6 +1,6 @@
<%
performing = @task.can_complete?(authenticated)
- iframe_url = @task.rendering.render_url(performing,
'task_url'=>task_for_person_url(@task, authenticated))
+ iframe_url = @task.rendering.render_url(performing) { {
'task_url'=>task_for_person_url(@task, authenticated) } }
%>
<% div_for @task do %>
<div class='header'>
Modified: ode/sandbox/singleshot/public/stylesheets/default.css
URL:
http://svn.apache.org/viewvc/ode/sandbox/singleshot/public/stylesheets/default.css?rev=663781&r1=663780&r2=663781&view=diff
==============================================================================
--- ode/sandbox/singleshot/public/stylesheets/default.css (original)
+++ ode/sandbox/singleshot/public/stylesheets/default.css Thu Jun 5 16:31:16
2008
@@ -355,7 +355,7 @@
}
div.task div.description {
- padding: 3em;
+ padding: 5em 3em 3em 3em;
}
div.task iframe {
Modified: ode/sandbox/singleshot/spec/models/helper.rb
URL:
http://svn.apache.org/viewvc/ode/sandbox/singleshot/spec/models/helper.rb?rev=663781&r1=663780&r2=663781&view=diff
==============================================================================
--- ode/sandbox/singleshot/spec/models/helper.rb (original)
+++ ode/sandbox/singleshot/spec/models/helper.rb Thu Jun 5 16:31:16 2008
@@ -12,7 +12,7 @@
end
def person(identity)
- Person.identify(identity) || Person.create(:email=>"[EMAIL PROTECTED]",
:password=>'secret')
+ Person.identify(identity) rescue Person.create(:email=>"[EMAIL
PROTECTED]", :password=>'secret')
end
def people(*identities)
Modified: ode/sandbox/singleshot/spec/models/stakeholder_spec.rb
URL:
http://svn.apache.org/viewvc/ode/sandbox/singleshot/spec/models/stakeholder_spec.rb?rev=663781&r1=663780&r2=663781&view=diff
==============================================================================
--- ode/sandbox/singleshot/spec/models/stakeholder_spec.rb (original)
+++ ode/sandbox/singleshot/spec/models/stakeholder_spec.rb Thu Jun 5 16:31:16
2008
@@ -157,6 +157,12 @@
Task.last.owner.should be_nil
end
+ it 'should treat empty string as nil' do
+ Task.create! defaults.merge(:owner=>person('owner'))
+ Task.last.update_attributes! :owner=>''
+ Task.last.owner.should be_nil
+ end
+
it 'should not allow owner if listed in excluded owners' do
Task.create! defaults.merge(:excluded_owners=>person('excluded'))
lambda { Task.last.update_attributes! :owner=>person('excluded')
}.should raise_error
Modified: ode/sandbox/singleshot/spec/models/task_spec.rb
URL:
http://svn.apache.org/viewvc/ode/sandbox/singleshot/spec/models/task_spec.rb?rev=663781&r1=663780&r2=663781&view=diff
==============================================================================
--- ode/sandbox/singleshot/spec/models/task_spec.rb (original)
+++ ode/sandbox/singleshot/spec/models/task_spec.rb Thu Jun 5 16:31:16 2008
@@ -385,6 +385,7 @@
it 'should have nil render_url without perform_url' do
Task.new.rendering.render_url(true).should be_nil
+ Task.new.rendering.render_url(true) { fail }.should be_nil
end
it 'should render using perform_url when performing task' do
@@ -399,6 +400,7 @@
it 'should have nil render_url without details_url' do
Task.new(:perform_url=>'http://foobar/').rendering.render_url(false).should
be_nil
+ Task.new.rendering.render_url(false) { fail }.should be_nil
end
it 'should render using details_url when performing task' do
@@ -450,51 +452,6 @@
=begin
-describe Task, 'url', :shared=>true do
-
- it 'should be tested for validity' do
- Task.new(@field=>'http://+++').should have(1).error_on(@field)
- end
-
- it 'should allow HTTP URLS' do
- Task.new(@field=>'http://test.host/do').should have(:no).errors_on(@field)
- end
-
- it 'should allow HTTPS URLS' do
- Task.new(@field=>'https://test.host/do').should have(:no).errors_on(@field)
- end
-
- it 'should not allow other URL schemes' do
- Task.new(@field=>'ftp://test.host/do').should have(1).error_on(@field)
- end
-
- it 'should store normalized URL' do
- task = Task.new(@field=>'HTTP://Test.Host/Foo')
- task.should have(:no).errors_on(@field)
- task.send(@field).should eql('http://test.host/Foo')
- end
-
- it 'should be modifiable' do
- task = Task.new(@field=>'http://test.host/view')
- lambda { task.update_attributes @field=>'http://test.host/' }.should
change(task, @field).to('http://test.host/')
- end
-
-end
-
-
-describe Task, 'frame_url' do
- it_should_behave_like 'Task url'
-
- before :all do
- @field = :frame_url
- end
-
- it 'should be required for active task' do
- Task.new.should have(1).errors_on(:frame_url)
- end
-
-end
-
describe Task, 'outcome_url' do
it_should_behave_like 'Task url'
@@ -605,95 +562,4 @@
end
-describe Task, 'stakeholder?' do
-
- before :all do
- @task = Task.new(@roles = all_roles)
- @task.excluded_owners = [person('excluded'), @task.potential_owners[1]]
- @task.save
- end
-
- it 'should return true if person associated with task' do
- allowed = @roles.map { |role, people| Array(people) }.flatten -
@task.excluded_owners
- allowed.size.should > 0
- allowed.each { |person| @task.stakeholder?(person).should be_true }
- end
-
- it 'should return false if person not associated with task' do
- @task.stakeholder?(person(:unknown)).should be_false
- end
-
- it 'should return true for task admin' do
- @task.stakeholder?(su).should be_true
- end
-
- it 'should return false for excluded owner' do
- @task.excluded_owners.each { |person| @task.stakeholder?(person).should
be_false }
- end
-
-end
-
-
-describe Task, 'stakeholders' do
-
- it 'should be protected attribute' do
- task = Task.new(:stakeholders=>[Stakeholder.new])
- task.stakeholders.should be_empty
- lambda { task.update_attributes :stakeholders=>[Stakeholder.new]
}.should_not change(task, :stakeholders)
- end
-
-end
-
-
-describe Task, 'cancellation' do
-
- before :each do
- @task = Task.new(defaults(@roles = all_roles))
- end
-
- it 'should default to :admin' do
- @task.cancellation.should eql(:admin)
- end
-
- it 'should accept :owner' do
- lambda { @task.update_attributes! :cancellation=>:owner }.should
change(@task, :cancellation).to(:owner)
- end
-
- it 'should allow admin to cancel the task for all values' do
- @roles.select { |role, people| Array(people).any? { |person|
@task.can_cancel?(person) } }.
- map(&:first).should eql([:admins])
- @task.can_cancel?(su).should be_true
- end
-
- it 'should allow owner to cancel the task for the value :owner' do
- @task.cancellation = :owner
- @roles.select { |role, people| Array(people).any? { |person|
@task.can_cancel?(person) } }.
- map(&:first).sort_by(&:to_s).should eql([:admins, :owner])
- @task.can_cancel?(su).should be_true
- end
-
-end
-
-
-describe Task, 'completion' do
-
- before :all do
- @roles = all_roles
- end
-
- before :each do
- @task = Task.create(defaults(@roles))
- end
-
- it 'should allow owner to complete task' do
- @roles.select { |role, people| Array(people).any? { |person|
@task.can_complete?(person) } }.
- map(&:first).should eql([:owner])
- end
-
- it 'should not validate if completed without owner' do
- @task.status = :completed
- lambda { @task.owner = nil }.should change { @task.valid? }.to(false)
- end
-
-end
=end