Commit f5aeac9a0a54a763f6a4375443686d9048bc40d9
1 parent
5fb63731
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
adding search task specific for task controler to make permission control
Showing
3 changed files
with
14 additions
and
6 deletions
Show diff stats
app/controllers/my_profile/tasks_controller.rb
1 | 1 | class TasksController < MyProfileController |
2 | 2 | |
3 | - protect [:perform_task, :view_tasks], :profile, :only => [:index, :save_tags] | |
4 | - protect :perform_task, :profile, :except => [:index, :save_tags] | |
3 | + protect [:perform_task, :view_tasks], :profile, :only => [:index, :save_tags, :search_tags] | |
4 | + protect :perform_task, :profile, :except => [:index, :save_tags, :search_tags] | |
5 | 5 | |
6 | 6 | def index |
7 | 7 | @filter_type = params[:filter_type].presence |
... | ... | @@ -114,4 +114,15 @@ class TasksController < MyProfileController |
114 | 114 | render json: result |
115 | 115 | end |
116 | 116 | |
117 | + #FIXME make this test | |
118 | + # Should not search for article tasks | |
119 | + # Should not search for other profile tags | |
120 | + # Should search only task tags | |
121 | + # Should check the permissions | |
122 | + def search_tags | |
123 | + arg = params[:term].downcase | |
124 | + result = ActsAsTaggableOn::Tag.find(:all, :conditions => ['LOWER(name) LIKE ?', "%#{arg}%"]) | |
125 | + render :text => prepare_to_token_input_by_label(result).to_json, :content_type => 'application/json' | |
126 | + end | |
127 | + | |
117 | 128 | end | ... | ... |
app/views/tasks/index.html.erb
... | ... | @@ -107,7 +107,7 @@ |
107 | 107 | }); |
108 | 108 | |
109 | 109 | jQuery('.tag-list').inputosaurus({ |
110 | - autoCompleteSource: <%= "'/myprofile/#{profile.identifier}/cms/search_tags'," %> | |
110 | + autoCompleteSource: <%= "'/myprofile/#{profile.identifier}/tasks/search_tags'," %> | |
111 | 111 | activateFinalResult: true, |
112 | 112 | submitTags: { |
113 | 113 | url: <%= "'/myprofile/#{profile.identifier}/tasks/save_tags'" %>, | ... | ... |
test/functional/tasks_controller_test.rb
... | ... | @@ -684,9 +684,6 @@ class TasksControllerTest < ActionController::TestCase |
684 | 684 | |
685 | 685 | assert_not_includes task_one.tags_from(nil), 'test' |
686 | 686 | end |
687 | -#region_validators_controller_test.rb: give_permission('ze', 'manage_environment_validators', environment) | |
688 | -#profile_editor_controller_test.rb: user2.stubs(:has_permission?).with('edit_profile', anything).returns(true) | |
689 | -#profile_editor_controller_test.rb: user2.expects(:has_permission?).with(:manage_friends, anything).returns(true) | |
690 | 687 | |
691 | 688 | should 'not tag task with permission but another user' do |
692 | 689 | requestor = fast_create(Person) | ... | ... |