Commit 1d34da73686b4314e818398120484bda4138f0e8

Authored by AntonioTerceiro
1 parent 804cafe1

ActionItem36: a first stab on a tasks controller


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1487 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/controllers/my_profile/tasks_controller.rb 0 → 100644
... ... @@ -0,0 +1,7 @@
  1 +class TasksController < MyProfileController
  2 +
  3 + def index
  4 + @tasks = profile.tasks.pending
  5 + end
  6 +
  7 +end
... ...
app/views/tasks/_add_friend.rhtml 0 → 100644
... ... @@ -0,0 +1,22 @@
  1 +<h2><%= _('New friend') %></h2>
  2 +
  3 +<p>
  4 +<%= _('%s wants to connect to you as a friend.') % task.requestor.name %>
  5 +</p>
  6 +
  7 +<% labelled_form_for('task', task, :url => { :action => 'close', :id => task.id } ) do |f| %>
  8 +
  9 + <div>
  10 + <%= radio_button_tag(:action, 'accept', true) %>
  11 + <%= _('Accept') %>
  12 + </div>
  13 +
  14 + <div>
  15 + <%= radio_button_tag(:action, 'ignore', false) %>
  16 + <%= _('Ignore') %>
  17 + </div>
  18 +
  19 + <% button_bar do %>
  20 + <%= submit_button(:ok, _('OK')) %>
  21 + <% end %>
  22 +<% end %>
... ...
app/views/tasks/index.rhtml 0 → 100644
... ... @@ -0,0 +1,7 @@
  1 +<h1><%= _('Pending tasks') %></h1>
  2 +
  3 +<ul class='task-list'>
  4 + <% @tasks.each do |item| %>
  5 + <li><%= render :partial => partial_for_class(item.class), :locals => { :task => item } %></li>
  6 + <% end %>
  7 +</ul>
... ...
db/migrate/023_add_type_column_for_task.rb 0 → 100644
... ... @@ -0,0 +1,9 @@
  1 +class AddTypeColumnForTask < ActiveRecord::Migration
  2 + def self.up
  3 + add_column :tasks, :type, :string
  4 + end
  5 +
  6 + def self.down
  7 + remove_column :tasks, :type
  8 + end
  9 +end
... ...
test/functional/tasks_controller_test.rb 0 → 100644
... ... @@ -0,0 +1,33 @@
  1 +require File.dirname(__FILE__) + '/../test_helper'
  2 +require 'tasks_controller'
  3 +
  4 +class TasksController; def rescue_action(e) raise e end; end
  5 +
  6 +class TasksControllerTest < Test::Unit::TestCase
  7 +
  8 + noosfero_test :profile => 'testuser'
  9 +
  10 + def setup
  11 + @controller = TasksController.new
  12 + @request = ActionController::TestRequest.new
  13 + @response = ActionController::TestResponse.new
  14 +
  15 + self.profile = create_user('testuser').person
  16 + end
  17 + attr_accessor :profile
  18 +
  19 + should 'list pending tasks' do
  20 + get :index
  21 +
  22 + assert_response :success
  23 + assert_template 'index'
  24 + assert_kind_of Array, assigns(:tasks)
  25 + end
  26 +
  27 + should 'display form for resolving a task'
  28 +
  29 + should 'be able to finish a task'
  30 +
  31 + should 'be able to cancel a task'
  32 +
  33 +end
... ...