diff --git a/app/controllers/application.rb b/app/controllers/application.rb index f7ad76e..a42f0af 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -17,4 +17,11 @@ class ApplicationController < ActionController::Base end end + def self.acts_as_admin_controller + before_filter :load_admin_controller + end + def load_admin_controller + # TODO: check access control + end + end diff --git a/app/controllers/features_controller.rb b/app/controllers/features_controller.rb new file mode 100644 index 0000000..06c0eef --- /dev/null +++ b/app/controllers/features_controller.rb @@ -0,0 +1,7 @@ +class FeaturesController < ApplicationController + acts_as_admin_controller + + def index + @features = VirtualCommunity::EXISTING_FEATURES + end +end diff --git a/app/helpers/features_helper.rb b/app/helpers/features_helper.rb new file mode 100644 index 0000000..1a5e6b2 --- /dev/null +++ b/app/helpers/features_helper.rb @@ -0,0 +1,2 @@ +module FeaturesHelper +end diff --git a/app/models/virtual_community.rb b/app/models/virtual_community.rb index 5f15bd1..5f53239 100644 --- a/app/models/virtual_community.rb +++ b/app/models/virtual_community.rb @@ -2,9 +2,9 @@ class VirtualCommunity < ActiveRecord::Base # TODO: these are test features EXISTING_FEATURES = { - 'feature1' => _('Feature 1'), - 'feature2' => _('Feature 2'), - 'feature3' => _('Feature 3'), + 'feature1' => _('Enable Feature 1'), + 'feature2' => _('Enable Feature 2'), + 'feature3' => _('Enable Feature 3'), } # ################################################# diff --git a/app/views/features/index.rhtml b/app/views/features/index.rhtml new file mode 100644 index 0000000..4fff680 --- /dev/null +++ b/app/views/features/index.rhtml @@ -0,0 +1,13 @@ +

<%= _('Enable/Disable features') %>

+ + + <% form_tag({:action => 'update_features'}) do %> + <% @features.each do |feature, text| %> + + + + + <% end %> + + <% end %> +
<%= text %><%= check_box_tag "feature[#{feature}]" %>
<%= submit_tag %>
diff --git a/test/functional/features_controller_test.rb b/test/functional/features_controller_test.rb new file mode 100644 index 0000000..227d9bc --- /dev/null +++ b/test/functional/features_controller_test.rb @@ -0,0 +1,26 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'features_controller' + +# Re-raise errors caught by the controller. +class FeaturesController; def rescue_action(e) raise e end; end + +class FeaturesControllerTest < Test::Unit::TestCase + def setup + @controller = FeaturesController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + end + + def test_listing_features + get :index + assert_template 'index' + VirtualCommunity::EXISTING_FEATURES.each do |feature, text| + assert_tag(:tag => 'input', :attributes => { :type => 'checkbox', :name => "feature[#{feature}]" }) + end + end + + def test_update_features + fail 'Not implemented yet' + end + +end -- libgit2 0.21.2