Sha256: 3b7e09a312c50bcdb32326d7d316068d2816a653eb78592ee9ec687fe329c8a3
Contents?: true
Size: 1.21 KB
Versions: 3
Compression:
Stored size: 1.21 KB
Contents
require 'foreman_tasks_test_helper' class TasksTest < ActiveSupport::TestCase describe 'filtering by current user' do before { @original_current_user = User.current } after { User.current = @original_current_user } test "can search the tasks by current_user" do user_one = FactoryGirl.create(:user) user_two = FactoryGirl.create(:user) task_one = FactoryGirl.create(:some_task, :set_owner => user_one) task_two = FactoryGirl.create(:some_task, :set_owner => user_two) User.current = user_one assert_equal [task_one], ForemanTasks::Task.search_for("owner.id = current_user") end end describe 'authorization filtering' do it 'can filter by the task subject' do user_role = FactoryGirl.create(:user_user_role) user = user_role.owner role = user_role.role permission = FactoryGirl.build(:permission) permission.resource_type = 'ForemanTasks::Task' permission.save! FactoryGirl.create(:filter, :role => role, :permissions => [permission]) User.current = user task = FactoryGirl.create(:dynflow_task) auth = Authorizer.new(user) assert auth.can?(permission.name.to_sym, task) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
foreman-tasks-0.6.13 | test/unit/task_test.rb |
foreman-tasks-0.6.12 | test/unit/task_test.rb |
foreman-tasks-0.6.11 | test/unit/task_test.rb |