From 1d34da73686b4314e818398120484bda4138f0e8 Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Fri, 22 Feb 2008 23:07:20 +0000 Subject: [PATCH] ActionItem36: a first stab on a tasks controller --- app/controllers/my_profile/tasks_controller.rb | 7 +++++++ app/views/tasks/_add_friend.rhtml | 22 ++++++++++++++++++++++ app/views/tasks/index.rhtml | 7 +++++++ db/migrate/023_add_type_column_for_task.rb | 9 +++++++++ test/functional/tasks_controller_test.rb | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 78 insertions(+), 0 deletions(-) create mode 100644 app/controllers/my_profile/tasks_controller.rb create mode 100644 app/views/tasks/_add_friend.rhtml create mode 100644 app/views/tasks/index.rhtml create mode 100644 db/migrate/023_add_type_column_for_task.rb create mode 100644 test/functional/tasks_controller_test.rb diff --git a/app/controllers/my_profile/tasks_controller.rb b/app/controllers/my_profile/tasks_controller.rb new file mode 100644 index 0000000..1f4371d --- /dev/null +++ b/app/controllers/my_profile/tasks_controller.rb @@ -0,0 +1,7 @@ +class TasksController < MyProfileController + + def index + @tasks = profile.tasks.pending + end + +end diff --git a/app/views/tasks/_add_friend.rhtml b/app/views/tasks/_add_friend.rhtml new file mode 100644 index 0000000..8ed59fa --- /dev/null +++ b/app/views/tasks/_add_friend.rhtml @@ -0,0 +1,22 @@ +

<%= _('New friend') %>

+ +

+<%= _('%s wants to connect to you as a friend.') % task.requestor.name %> +

+ +<% labelled_form_for('task', task, :url => { :action => 'close', :id => task.id } ) do |f| %> + +
+ <%= radio_button_tag(:action, 'accept', true) %> + <%= _('Accept') %> +
+ +
+ <%= radio_button_tag(:action, 'ignore', false) %> + <%= _('Ignore') %> +
+ + <% button_bar do %> + <%= submit_button(:ok, _('OK')) %> + <% end %> +<% end %> diff --git a/app/views/tasks/index.rhtml b/app/views/tasks/index.rhtml new file mode 100644 index 0000000..14430c3 --- /dev/null +++ b/app/views/tasks/index.rhtml @@ -0,0 +1,7 @@ +

<%= _('Pending tasks') %>

+ + diff --git a/db/migrate/023_add_type_column_for_task.rb b/db/migrate/023_add_type_column_for_task.rb new file mode 100644 index 0000000..57288c2 --- /dev/null +++ b/db/migrate/023_add_type_column_for_task.rb @@ -0,0 +1,9 @@ +class AddTypeColumnForTask < ActiveRecord::Migration + def self.up + add_column :tasks, :type, :string + end + + def self.down + remove_column :tasks, :type + end +end diff --git a/test/functional/tasks_controller_test.rb b/test/functional/tasks_controller_test.rb new file mode 100644 index 0000000..88acb06 --- /dev/null +++ b/test/functional/tasks_controller_test.rb @@ -0,0 +1,33 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'tasks_controller' + +class TasksController; def rescue_action(e) raise e end; end + +class TasksControllerTest < Test::Unit::TestCase + + noosfero_test :profile => 'testuser' + + def setup + @controller = TasksController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + + self.profile = create_user('testuser').person + end + attr_accessor :profile + + should 'list pending tasks' do + get :index + + assert_response :success + assert_template 'index' + assert_kind_of Array, assigns(:tasks) + end + + should 'display form for resolving a task' + + should 'be able to finish a task' + + should 'be able to cancel a task' + +end -- libgit2 0.21.2