Commit 03f7cd2a46f0252fcff46f3c3de9c9456436c4d8

Authored by AntonioTerceiro
1 parent fa43549d

ActionItem3: starting features_controller



git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@57 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/controllers/application.rb
... ... @@ -17,4 +17,11 @@ class ApplicationController < ActionController::Base
17 17 end
18 18 end
19 19  
  20 + def self.acts_as_admin_controller
  21 + before_filter :load_admin_controller
  22 + end
  23 + def load_admin_controller
  24 + # TODO: check access control
  25 + end
  26 +
20 27 end
... ...
app/controllers/features_controller.rb 0 → 100644
... ... @@ -0,0 +1,7 @@
  1 +class FeaturesController < ApplicationController
  2 + acts_as_admin_controller
  3 +
  4 + def index
  5 + @features = VirtualCommunity::EXISTING_FEATURES
  6 + end
  7 +end
... ...
app/helpers/features_helper.rb 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +module FeaturesHelper
  2 +end
... ...
app/models/virtual_community.rb
... ... @@ -2,9 +2,9 @@ class VirtualCommunity &lt; ActiveRecord::Base
2 2  
3 3 # TODO: these are test features
4 4 EXISTING_FEATURES = {
5   - 'feature1' => _('Feature 1'),
6   - 'feature2' => _('Feature 2'),
7   - 'feature3' => _('Feature 3'),
  5 + 'feature1' => _('Enable Feature 1'),
  6 + 'feature2' => _('Enable Feature 2'),
  7 + 'feature3' => _('Enable Feature 3'),
8 8 }
9 9  
10 10 # #################################################
... ...
app/views/features/index.rhtml 0 → 100644
... ... @@ -0,0 +1,13 @@
  1 +<h2><%= _('Enable/Disable features') %></h2>
  2 +
  3 +<table>
  4 + <% form_tag({:action => 'update_features'}) do %>
  5 + <% @features.each do |feature, text| %>
  6 + <tr>
  7 + <td><%= text %></td>
  8 + <td><%= check_box_tag "feature[#{feature}]" %></td>
  9 + </tr>
  10 + <% end %>
  11 + <tr><td colspan='2'><%= submit_tag %></td></tr>
  12 + <% end %>
  13 +</table>
... ...
test/functional/features_controller_test.rb 0 → 100644
... ... @@ -0,0 +1,26 @@
  1 +require File.dirname(__FILE__) + '/../test_helper'
  2 +require 'features_controller'
  3 +
  4 +# Re-raise errors caught by the controller.
  5 +class FeaturesController; def rescue_action(e) raise e end; end
  6 +
  7 +class FeaturesControllerTest < Test::Unit::TestCase
  8 + def setup
  9 + @controller = FeaturesController.new
  10 + @request = ActionController::TestRequest.new
  11 + @response = ActionController::TestResponse.new
  12 + end
  13 +
  14 + def test_listing_features
  15 + get :index
  16 + assert_template 'index'
  17 + VirtualCommunity::EXISTING_FEATURES.each do |feature, text|
  18 + assert_tag(:tag => 'input', :attributes => { :type => 'checkbox', :name => "feature[#{feature}]" })
  19 + end
  20 + end
  21 +
  22 + def test_update_features
  23 + fail 'Not implemented yet'
  24 + end
  25 +
  26 +end
... ...