Commit f618532903dcf3fbca76f9e98eeffe375d654dc2
1 parent
7e162ba3
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
refactoring some tasks controller tests
Showing
1 changed file
with
99 additions
and
89 deletions
Show diff stats
test/functional/tasks_controller_test.rb
| @@ -12,14 +12,14 @@ class TasksControllerTest < ActionController::TestCase | @@ -12,14 +12,14 @@ class TasksControllerTest < ActionController::TestCase | ||
| 12 | @request = ActionController::TestRequest.new | 12 | @request = ActionController::TestRequest.new |
| 13 | @response = ActionController::TestResponse.new | 13 | @response = ActionController::TestResponse.new |
| 14 | 14 | ||
| 15 | - self.profile = create_user('testuser').person | ||
| 16 | - @controller.stubs(:profile).returns(profile) | 15 | + @person = create_user('testuser').person |
| 16 | + @controller.stubs(:profile).returns(@person) | ||
| 17 | login_as 'testuser' | 17 | login_as 'testuser' |
| 18 | end | 18 | end |
| 19 | - attr_accessor :profile | 19 | + attr_accessor :person |
| 20 | 20 | ||
| 21 | def assert_redirected_to(options) | 21 | def assert_redirected_to(options) |
| 22 | - super({ :controller => 'tasks', :profile => profile.identifier }.merge(options)) | 22 | + super({ :controller => 'tasks', :profile => person.identifier }.merge(options)) |
| 23 | end | 23 | end |
| 24 | 24 | ||
| 25 | should 'list pending tasks' do | 25 | should 'list pending tasks' do |
| @@ -32,8 +32,8 @@ class TasksControllerTest < ActionController::TestCase | @@ -32,8 +32,8 @@ class TasksControllerTest < ActionController::TestCase | ||
| 32 | 32 | ||
| 33 | should 'list pending tasks without spam' do | 33 | should 'list pending tasks without spam' do |
| 34 | requestor = fast_create(Person) | 34 | requestor = fast_create(Person) |
| 35 | - task_spam = Task.create!(:requestor => requestor, :target => profile, :spam => true) | ||
| 36 | - task_ham = Task.create!(:requestor => requestor, :target => profile, :spam => false) | 35 | + task_spam = Task.create!(:requestor => requestor, :target => person, :spam => true) |
| 36 | + task_ham = Task.create!(:requestor => requestor, :target => person, :spam => false) | ||
| 37 | 37 | ||
| 38 | get :index | 38 | get :index |
| 39 | assert_response :success | 39 | assert_response :success |
| @@ -50,15 +50,15 @@ class TasksControllerTest < ActionController::TestCase | @@ -50,15 +50,15 @@ class TasksControllerTest < ActionController::TestCase | ||
| 50 | end | 50 | end |
| 51 | 51 | ||
| 52 | should 'display task created_at' do | 52 | should 'display task created_at' do |
| 53 | - Task.create!(:requestor => fast_create(Person), :target => profile, :spam => false) | 53 | + Task.create!(:requestor => fast_create(Person), :target => person, :spam => false) |
| 54 | get :index | 54 | get :index |
| 55 | assert_select '.task_date' | 55 | assert_select '.task_date' |
| 56 | end | 56 | end |
| 57 | 57 | ||
| 58 | should 'list processed tasks without spam' do | 58 | should 'list processed tasks without spam' do |
| 59 | requestor = fast_create(Person) | 59 | requestor = fast_create(Person) |
| 60 | - task_spam = create(Task, :status => Task::Status::FINISHED, :requestor => requestor, :target => profile, :spam => true) | ||
| 61 | - task_ham = create(Task, :status => Task::Status::FINISHED, :requestor => requestor, :target => profile, :spam => false) | 60 | + task_spam = create(Task, :status => Task::Status::FINISHED, :requestor => requestor, :target => person, :spam => true) |
| 61 | + task_ham = create(Task, :status => Task::Status::FINISHED, :requestor => requestor, :target => person, :spam => false) | ||
| 62 | 62 | ||
| 63 | get :processed | 63 | get :processed |
| 64 | assert_response :success | 64 | assert_response :success |
| @@ -66,23 +66,8 @@ class TasksControllerTest < ActionController::TestCase | @@ -66,23 +66,8 @@ class TasksControllerTest < ActionController::TestCase | ||
| 66 | assert_not_includes assigns(:tasks), task_spam | 66 | assert_not_includes assigns(:tasks), task_spam |
| 67 | end | 67 | end |
| 68 | 68 | ||
| 69 | - should 'save tasks tags' do | ||
| 70 | - | ||
| 71 | - requestor = fast_create(Person) | ||
| 72 | - | ||
| 73 | - task_one = Task.create!(:requestor => requestor, :target => profile, :data => {:name => 'Task Test'}) | ||
| 74 | - task_two = Task.create!(:requestor => requestor, :target => profile, :data => {:name => 'Another Task'}) | ||
| 75 | - | ||
| 76 | - post :save_tags, :task_id => task_one.id, :tag_list => 'noosfero,test' | ||
| 77 | - post :save_tags, :task_id => task_two.id, :tag_list => 'test' | ||
| 78 | - | ||
| 79 | - assert_includes task_one.tags_from(nil), 'test' | ||
| 80 | - assert_not_includes task_two.tags_from(nil), 'noosfero' | ||
| 81 | - | ||
| 82 | - end | ||
| 83 | - | ||
| 84 | should 'be able to finish a task' do | 69 | should 'be able to finish a task' do |
| 85 | - t = profile.tasks.build; t.save! | 70 | + t = person.tasks.build; t.save! |
| 86 | 71 | ||
| 87 | post :close, :tasks => {t.id => {:decision => 'finish', :task => {}}} | 72 | post :close, :tasks => {t.id => {:decision => 'finish', :task => {}}} |
| 88 | assert_redirected_to :action => 'index' | 73 | assert_redirected_to :action => 'index' |
| @@ -92,7 +77,7 @@ class TasksControllerTest < ActionController::TestCase | @@ -92,7 +77,7 @@ class TasksControllerTest < ActionController::TestCase | ||
| 92 | end | 77 | end |
| 93 | 78 | ||
| 94 | should 'be able to cancel a task' do | 79 | should 'be able to cancel a task' do |
| 95 | - t = profile.tasks.build; t.save! | 80 | + t = person.tasks.build; t.save! |
| 96 | 81 | ||
| 97 | post :close, :tasks => {t.id => {:decision => 'cancel', :task => {}}} | 82 | post :close, :tasks => {t.id => {:decision => 'cancel', :task => {}}} |
| 98 | assert_redirected_to :action => 'index' | 83 | assert_redirected_to :action => 'index' |
| @@ -102,7 +87,7 @@ class TasksControllerTest < ActionController::TestCase | @@ -102,7 +87,7 @@ class TasksControllerTest < ActionController::TestCase | ||
| 102 | end | 87 | end |
| 103 | 88 | ||
| 104 | should 'be able to skip a task' do | 89 | should 'be able to skip a task' do |
| 105 | - t = profile.tasks.build; t.save! | 90 | + t = person.tasks.build; t.save! |
| 106 | 91 | ||
| 107 | post :close, :tasks => {t.id => {:decision => 'skip', :task => {}}} | 92 | post :close, :tasks => {t.id => {:decision => 'skip', :task => {}}} |
| 108 | assert_redirected_to :action => 'index' | 93 | assert_redirected_to :action => 'index' |
| @@ -112,9 +97,9 @@ class TasksControllerTest < ActionController::TestCase | @@ -112,9 +97,9 @@ class TasksControllerTest < ActionController::TestCase | ||
| 112 | end | 97 | end |
| 113 | 98 | ||
| 114 | should 'be able to apply different decisions to multiples tasks at the same time' do | 99 | should 'be able to apply different decisions to multiples tasks at the same time' do |
| 115 | - t1 = profile.tasks.build; t1.save! | ||
| 116 | - t2 = profile.tasks.build; t2.save! | ||
| 117 | - t3 = profile.tasks.build; t3.save! | 100 | + t1 = person.tasks.build; t1.save! |
| 101 | + t2 = person.tasks.build; t2.save! | ||
| 102 | + t3 = person.tasks.build; t3.save! | ||
| 118 | 103 | ||
| 119 | post :close, :tasks => {t1.id => {:decision => 'finish', :task => {}}, t2.id => {:decision => 'cancel', :task => {}}, t3.id => {:decision => 'skip', :task => {}}} | 104 | post :close, :tasks => {t1.id => {:decision => 'finish', :task => {}}, t2.id => {:decision => 'cancel', :task => {}}, t3.id => {:decision => 'skip', :task => {}}} |
| 120 | assert_redirected_to :action => 'index' | 105 | assert_redirected_to :action => 'index' |
| @@ -129,56 +114,60 @@ class TasksControllerTest < ActionController::TestCase | @@ -129,56 +114,60 @@ class TasksControllerTest < ActionController::TestCase | ||
| 129 | end | 114 | end |
| 130 | 115 | ||
| 131 | should 'affiliate roles to user after finish add member task' do | 116 | should 'affiliate roles to user after finish add member task' do |
| 132 | - t = AddMember.create!(:person => profile, :organization => profile) | ||
| 133 | - count = profile.members.size | 117 | + community = fast_create(Community) |
| 118 | + community.add_member(person) | ||
| 119 | + another_person = fast_create(Person) | ||
| 120 | + t = AddMember.create!(:person => another_person, :organization => community) | ||
| 121 | + count = community.members.size | ||
| 122 | + @controller.stubs(:profile).returns(community) | ||
| 134 | post :close, :tasks => {t.id => {:decision => 'finish', :task => {}}} | 123 | post :close, :tasks => {t.id => {:decision => 'finish', :task => {}}} |
| 135 | - profile = Profile.find(@profile.id) | ||
| 136 | - assert_equal count + 1, profile.members.size | 124 | + community = Profile.find(community.id) |
| 125 | + assert_equal count + 1, community.members.size | ||
| 137 | end | 126 | end |
| 138 | 127 | ||
| 139 | should 'display a create ticket form' do | 128 | should 'display a create ticket form' do |
| 140 | - get :new, :profile => profile.identifier | 129 | + get :new, :profile => person.identifier |
| 141 | 130 | ||
| 142 | assert_template 'new' | 131 | assert_template 'new' |
| 143 | end | 132 | end |
| 144 | 133 | ||
| 145 | should 'add a hidden field with target_id when informed in the URL' do | 134 | should 'add a hidden field with target_id when informed in the URL' do |
| 146 | friend = create_user('myfriend').person | 135 | friend = create_user('myfriend').person |
| 147 | - profile.add_friend(friend) | 136 | + person.add_friend(friend) |
| 148 | 137 | ||
| 149 | - get :new, :profile => profile.identifier, :target_id => friend.id.to_s | 138 | + get :new, :profile => person.identifier, :target_id => friend.id.to_s |
| 150 | 139 | ||
| 151 | assert_tag :tag => 'input', :attributes => { :type => 'hidden', :name => 'ticket[target_id]', :value => friend.id } | 140 | assert_tag :tag => 'input', :attributes => { :type => 'hidden', :name => 'ticket[target_id]', :value => friend.id } |
| 152 | end | 141 | end |
| 153 | 142 | ||
| 154 | should 'select friend from list when not already informed' do | 143 | should 'select friend from list when not already informed' do |
| 155 | - get :new, :profile => profile.identifier | 144 | + get :new, :profile => person.identifier |
| 156 | assert_tag :tag => 'select', :attributes => { :name => 'ticket[target_id]' } | 145 | assert_tag :tag => 'select', :attributes => { :name => 'ticket[target_id]' } |
| 157 | end | 146 | end |
| 158 | 147 | ||
| 159 | should 'create a ticket' do | 148 | should 'create a ticket' do |
| 160 | assert_difference 'Ticket.count' do | 149 | assert_difference 'Ticket.count' do |
| 161 | - post :new, :profile => profile.identifier, :ticket => {:name => 'test ticket'} | 150 | + post :new, :profile => person.identifier, :ticket => {:name => 'test ticket'} |
| 162 | end | 151 | end |
| 163 | end | 152 | end |
| 164 | 153 | ||
| 165 | should 'create a ticket with profile requestor' do | 154 | should 'create a ticket with profile requestor' do |
| 166 | - post :new, :profile => profile.identifier, :ticket => {:name => 'new task'} | 155 | + post :new, :profile => person.identifier, :ticket => {:name => 'new task'} |
| 167 | 156 | ||
| 168 | - assert_equal profile, assigns(:ticket).requestor | 157 | + assert_equal person, assigns(:ticket).requestor |
| 169 | end | 158 | end |
| 170 | 159 | ||
| 171 | should 'list tasks that this profile created' do | 160 | should 'list tasks that this profile created' do |
| 172 | - task = Ticket.create!(:name => 'test', :requestor => profile) | ||
| 173 | - get :list_requested, :profile => profile.identifier | 161 | + task = Ticket.create!(:name => 'test', :requestor => person) |
| 162 | + get :list_requested, :profile => person.identifier | ||
| 174 | 163 | ||
| 175 | assert_includes assigns(:tasks), task | 164 | assert_includes assigns(:tasks), task |
| 176 | end | 165 | end |
| 177 | 166 | ||
| 178 | should 'list tasks that this profile created without spam' do | 167 | should 'list tasks that this profile created without spam' do |
| 179 | - task_spam = Ticket.create!(:name => 'test', :requestor => profile, :spam => true) | ||
| 180 | - task_ham = Ticket.create!(:name => 'test', :requestor => profile, :spam => false) | ||
| 181 | - get :list_requested, :profile => profile.identifier | 168 | + task_spam = Ticket.create!(:name => 'test', :requestor => person, :spam => true) |
| 169 | + task_ham = Ticket.create!(:name => 'test', :requestor => person, :spam => false) | ||
| 170 | + get :list_requested, :profile => person.identifier | ||
| 182 | 171 | ||
| 183 | assert_includes assigns(:tasks), task_ham | 172 | assert_includes assigns(:tasks), task_ham |
| 184 | assert_not_includes assigns(:tasks), task_spam | 173 | assert_not_includes assigns(:tasks), task_spam |
| @@ -186,9 +175,9 @@ class TasksControllerTest < ActionController::TestCase | @@ -186,9 +175,9 @@ class TasksControllerTest < ActionController::TestCase | ||
| 186 | 175 | ||
| 187 | should 'set target of ticket when creating it' do | 176 | should 'set target of ticket when creating it' do |
| 188 | f = create_user('friend').person | 177 | f = create_user('friend').person |
| 189 | - profile.add_friend f | 178 | + person.add_friend f |
| 190 | 179 | ||
| 191 | - post :new, :profile => profile.identifier, :ticket => {:name => 'test ticket', :target_id => f.id, :target_type => 'Profile'} | 180 | + post :new, :profile => person.identifier, :ticket => {:name => 'test ticket', :target_id => f.id, :target_type => 'Profile'} |
| 192 | assert_response :redirect | 181 | assert_response :redirect |
| 193 | 182 | ||
| 194 | assert_equal f, assigns(:ticket).target | 183 | assert_equal f, assigns(:ticket).target |
| @@ -198,9 +187,9 @@ class TasksControllerTest < ActionController::TestCase | @@ -198,9 +187,9 @@ class TasksControllerTest < ActionController::TestCase | ||
| 198 | c = fast_create(Community) | 187 | c = fast_create(Community) |
| 199 | c.update_attributes(:moderated_articles => false) | 188 | c.update_attributes(:moderated_articles => false) |
| 200 | @controller.stubs(:profile).returns(c) | 189 | @controller.stubs(:profile).returns(c) |
| 201 | - c.affiliate(profile, Profile::Roles.all_roles(profile.environment.id)) | ||
| 202 | - article = profile.articles.create!(:name => 'something interesting', :body => 'ruby on rails') | ||
| 203 | - t = ApproveArticle.create!(:name => 'test name', :article => article, :target => c, :requestor => profile) | 190 | + c.affiliate(person, Profile::Roles.all_roles(person.environment.id)) |
| 191 | + article = person.articles.create!(:name => 'something interesting', :body => 'ruby on rails') | ||
| 192 | + t = ApproveArticle.create!(:name => 'test name', :article => article, :target => c, :requestor => person) | ||
| 204 | 193 | ||
| 205 | post :close, :tasks => {t.id => {:decision => 'finish', :task => {:name => 'new_name'}}} | 194 | post :close, :tasks => {t.id => {:decision => 'finish', :task => {:name => 'new_name'}}} |
| 206 | assert_equal article, c.articles.find_by_name('new_name').reference_article | 195 | assert_equal article, c.articles.find_by_name('new_name').reference_article |
| @@ -211,9 +200,9 @@ class TasksControllerTest < ActionController::TestCase | @@ -211,9 +200,9 @@ class TasksControllerTest < ActionController::TestCase | ||
| 211 | c.update_attributes(:moderated_articles => false) | 200 | c.update_attributes(:moderated_articles => false) |
| 212 | @controller.stubs(:profile).returns(c) | 201 | @controller.stubs(:profile).returns(c) |
| 213 | folder = create(Folder, :profile => c, :name => 'test folder') | 202 | folder = create(Folder, :profile => c, :name => 'test folder') |
| 214 | - c.affiliate(profile, Profile::Roles.all_roles(profile.environment.id)) | ||
| 215 | - article = profile.articles.create!(:name => 'something interesting', :body => 'ruby on rails') | ||
| 216 | - t = ApproveArticle.create!(:name => 'test name', :article => article, :target => c, :requestor => profile) | 203 | + c.affiliate(person, Profile::Roles.all_roles(person.environment.id)) |
| 204 | + article = person.articles.create!(:name => 'something interesting', :body => 'ruby on rails') | ||
| 205 | + t = ApproveArticle.create!(:name => 'test name', :article => article, :target => c, :requestor => person) | ||
| 217 | 206 | ||
| 218 | post :close, :tasks => {t.id => {:decision => 'finish', :task => {:name => 'new_name', :article_parent_id => folder.id}}} | 207 | post :close, :tasks => {t.id => {:decision => 'finish', :task => {:name => 'new_name', :article_parent_id => folder.id}}} |
| 219 | assert_equal folder, c.articles.find_by_name('new_name').parent | 208 | assert_equal folder, c.articles.find_by_name('new_name').parent |
| @@ -224,9 +213,9 @@ class TasksControllerTest < ActionController::TestCase | @@ -224,9 +213,9 @@ class TasksControllerTest < ActionController::TestCase | ||
| 224 | c.update_attributes(:moderated_articles => false) | 213 | c.update_attributes(:moderated_articles => false) |
| 225 | @controller.stubs(:profile).returns(c) | 214 | @controller.stubs(:profile).returns(c) |
| 226 | folder = create(Article, :profile => c, :name => 'test folder', :type => 'Folder') | 215 | folder = create(Article, :profile => c, :name => 'test folder', :type => 'Folder') |
| 227 | - c.affiliate(profile, Profile::Roles.all_roles(profile.environment.id)) | ||
| 228 | - article = profile.articles.create!(:name => 'something interesting', :body => 'ruby on rails') | ||
| 229 | - t = ApproveArticle.create!(:article => article, :target => c, :requestor => profile) | 216 | + c.affiliate(person, Profile::Roles.all_roles(person.environment.id)) |
| 217 | + article = person.articles.create!(:name => 'something interesting', :body => 'ruby on rails') | ||
| 218 | + t = ApproveArticle.create!(:article => article, :target => c, :requestor => person) | ||
| 230 | 219 | ||
| 231 | post :close, :tasks => {t.id => {:decision => 'finish', :task => {:name => 'new_name', :article_parent_id => folder.id, :highlighted => true}}} | 220 | post :close, :tasks => {t.id => {:decision => 'finish', :task => {:name => 'new_name', :article_parent_id => folder.id, :highlighted => true}}} |
| 232 | assert_equal true, c.articles.find_by_name('new_name').highlighted | 221 | assert_equal true, c.articles.find_by_name('new_name').highlighted |
| @@ -236,9 +225,9 @@ class TasksControllerTest < ActionController::TestCase | @@ -236,9 +225,9 @@ class TasksControllerTest < ActionController::TestCase | ||
| 236 | c = fast_create(Community) | 225 | c = fast_create(Community) |
| 237 | c.update_attributes(:moderated_articles => false) | 226 | c.update_attributes(:moderated_articles => false) |
| 238 | @controller.stubs(:profile).returns(c) | 227 | @controller.stubs(:profile).returns(c) |
| 239 | - c.affiliate(profile, Profile::Roles.all_roles(profile.environment.id)) | ||
| 240 | - article = profile.articles.create!(:name => 'something interesting', :body => 'ruby on rails') | ||
| 241 | - t = ApproveArticle.create!(:article => article, :target => c, :requestor => profile) | 228 | + c.affiliate(person, Profile::Roles.all_roles(person.environment.id)) |
| 229 | + article = person.articles.create!(:name => 'something interesting', :body => 'ruby on rails') | ||
| 230 | + t = ApproveArticle.create!(:article => article, :target => c, :requestor => person) | ||
| 242 | 231 | ||
| 243 | post :close, :tasks => {t.id => {:decision => 'finish', :task => {:name => 'new_name', :article_parent_id => ""}}} | 232 | post :close, :tasks => {t.id => {:decision => 'finish', :task => {:name => 'new_name', :article_parent_id => ""}}} |
| 244 | assert_not_nil c.articles.find_by_name('new_name') | 233 | assert_not_nil c.articles.find_by_name('new_name') |
| @@ -247,7 +236,7 @@ class TasksControllerTest < ActionController::TestCase | @@ -247,7 +236,7 @@ class TasksControllerTest < ActionController::TestCase | ||
| 247 | should 'handle blank names for published articles' do | 236 | should 'handle blank names for published articles' do |
| 248 | c = fast_create(Community) | 237 | c = fast_create(Community) |
| 249 | @controller.stubs(:profile).returns(c) | 238 | @controller.stubs(:profile).returns(c) |
| 250 | - c.affiliate(profile, Profile::Roles.all_roles(c.environment)) | 239 | + c.affiliate(person, Profile::Roles.all_roles(c.environment)) |
| 251 | person = create_user('test_user').person | 240 | person = create_user('test_user').person |
| 252 | p_blog = Blog.create!(:profile => person, :name => 'Blog') | 241 | p_blog = Blog.create!(:profile => person, :name => 'Blog') |
| 253 | c_blog1 = Blog.create!(:profile => c, :name => 'Blog') | 242 | c_blog1 = Blog.create!(:profile => c, :name => 'Blog') |
| @@ -266,8 +255,8 @@ class TasksControllerTest < ActionController::TestCase | @@ -266,8 +255,8 @@ class TasksControllerTest < ActionController::TestCase | ||
| 266 | 255 | ||
| 267 | should 'display error if there is an enterprise with the same identifier and keep the task active' do | 256 | should 'display error if there is an enterprise with the same identifier and keep the task active' do |
| 268 | e = Environment.default | 257 | e = Environment.default |
| 269 | - e.add_admin(profile) | ||
| 270 | - task = CreateEnterprise.create!(:name => "My Enterprise", :identifier => "my-enterprise", :requestor => profile, :target => e) | 258 | + e.add_admin(person) |
| 259 | + task = CreateEnterprise.create!(:name => "My Enterprise", :identifier => "my-enterprise", :requestor => person, :target => e) | ||
| 271 | enterprise = fast_create(Enterprise, :name => "My Enterprise", :identifier => "my-enterprise") | 260 | enterprise = fast_create(Enterprise, :name => "My Enterprise", :identifier => "my-enterprise") |
| 272 | 261 | ||
| 273 | assert_nothing_raised do | 262 | assert_nothing_raised do |
| @@ -283,7 +272,7 @@ class TasksControllerTest < ActionController::TestCase | @@ -283,7 +272,7 @@ class TasksControllerTest < ActionController::TestCase | ||
| 283 | should 'render TinyMce Editor when approving suggested article task' do | 272 | should 'render TinyMce Editor when approving suggested article task' do |
| 284 | Task.destroy_all | 273 | Task.destroy_all |
| 285 | c = fast_create(Community) | 274 | c = fast_create(Community) |
| 286 | - c.add_admin profile | 275 | + c.add_admin person |
| 287 | @controller.stubs(:profile).returns(c) | 276 | @controller.stubs(:profile).returns(c) |
| 288 | t = SuggestArticle.create!(:article => {:name => 'test name', :abstract => 'test abstract', :body => 'test body'}, :name => 'some name', :email => 'test@localhost.com', :target => c) | 277 | t = SuggestArticle.create!(:article => {:name => 'test name', :abstract => 'test abstract', :body => 'test body'}, :name => 'some name', :email => 'test@localhost.com', :target => c) |
| 289 | 278 | ||
| @@ -295,7 +284,7 @@ class TasksControllerTest < ActionController::TestCase | @@ -295,7 +284,7 @@ class TasksControllerTest < ActionController::TestCase | ||
| 295 | should 'create TinyMceArticle article after finish approve suggested article task' do | 284 | should 'create TinyMceArticle article after finish approve suggested article task' do |
| 296 | TinyMceArticle.destroy_all | 285 | TinyMceArticle.destroy_all |
| 297 | c = fast_create(Community) | 286 | c = fast_create(Community) |
| 298 | - c.affiliate(profile, Profile::Roles.all_roles(profile.environment.id)) | 287 | + c.affiliate(person, Profile::Roles.all_roles(person.environment.id)) |
| 299 | @controller.stubs(:profile).returns(c) | 288 | @controller.stubs(:profile).returns(c) |
| 300 | t = SuggestArticle.create!(:article => {:name => 'test name', :body => 'test body'}, :name => 'some name', :email => 'test@localhost.com', :target => c) | 289 | t = SuggestArticle.create!(:article => {:name => 'test name', :body => 'test body'}, :name => 'some name', :email => 'test@localhost.com', :target => c) |
| 301 | 290 | ||
| @@ -306,7 +295,7 @@ class TasksControllerTest < ActionController::TestCase | @@ -306,7 +295,7 @@ class TasksControllerTest < ActionController::TestCase | ||
| 306 | should "change the article's attributes on suggested article task approval" do | 295 | should "change the article's attributes on suggested article task approval" do |
| 307 | TinyMceArticle.destroy_all | 296 | TinyMceArticle.destroy_all |
| 308 | c = fast_create(Community) | 297 | c = fast_create(Community) |
| 309 | - c.affiliate(profile, Profile::Roles.all_roles(profile.environment.id)) | 298 | + c.affiliate(person, Profile::Roles.all_roles(person.environment.id)) |
| 310 | @controller.stubs(:profile).returns(c) | 299 | @controller.stubs(:profile).returns(c) |
| 311 | t = SuggestArticle.new | 300 | t = SuggestArticle.new |
| 312 | t.article = {:name => 'test name', :body => 'test body', :source => 'http://test.com', :source_name => 'some source name'} | 301 | t.article = {:name => 'test name', :body => 'test body', :source => 'http://test.com', :source_name => 'some source name'} |
| @@ -326,7 +315,7 @@ class TasksControllerTest < ActionController::TestCase | @@ -326,7 +315,7 @@ class TasksControllerTest < ActionController::TestCase | ||
| 326 | should "display name from article suggestion when requestor was not setted" do | 315 | should "display name from article suggestion when requestor was not setted" do |
| 327 | Task.destroy_all | 316 | Task.destroy_all |
| 328 | c = fast_create(Community) | 317 | c = fast_create(Community) |
| 329 | - c.add_admin profile | 318 | + c.add_admin person |
| 330 | @controller.stubs(:profile).returns(c) | 319 | @controller.stubs(:profile).returns(c) |
| 331 | t = SuggestArticle.create!(:article => {:name => 'test name', :abstract => 'test abstract', :body => 'test body'}, :name => 'some name', :email => 'test@localhost.com', :target => c) | 320 | t = SuggestArticle.create!(:article => {:name => 'test name', :abstract => 'test abstract', :body => 'test body'}, :name => 'some name', :email => 'test@localhost.com', :target => c) |
| 332 | 321 | ||
| @@ -337,7 +326,7 @@ class TasksControllerTest < ActionController::TestCase | @@ -337,7 +326,7 @@ class TasksControllerTest < ActionController::TestCase | ||
| 337 | should "append hidden tag with type value from article suggestion" do | 326 | should "append hidden tag with type value from article suggestion" do |
| 338 | Task.destroy_all | 327 | Task.destroy_all |
| 339 | c = fast_create(Community) | 328 | c = fast_create(Community) |
| 340 | - c.add_admin profile | 329 | + c.add_admin person |
| 341 | @controller.stubs(:profile).returns(c) | 330 | @controller.stubs(:profile).returns(c) |
| 342 | t = SuggestArticle.create!(:article => {:name => 'test name', :abstract => 'test abstract', :body => 'test body', :type => 'TextArticle'}, :name => 'some name', :email => 'test@localhost.com', :target => c) | 331 | t = SuggestArticle.create!(:article => {:name => 'test name', :abstract => 'test abstract', :body => 'test body', :type => 'TextArticle'}, :name => 'some name', :email => 'test@localhost.com', :target => c) |
| 343 | 332 | ||
| @@ -348,7 +337,7 @@ class TasksControllerTest < ActionController::TestCase | @@ -348,7 +337,7 @@ class TasksControllerTest < ActionController::TestCase | ||
| 348 | should "display parent_id selection from article suggestion with predefined value" do | 337 | should "display parent_id selection from article suggestion with predefined value" do |
| 349 | Task.destroy_all | 338 | Task.destroy_all |
| 350 | c = fast_create(Community) | 339 | c = fast_create(Community) |
| 351 | - c.add_admin profile | 340 | + c.add_admin person |
| 352 | @controller.stubs(:profile).returns(c) | 341 | @controller.stubs(:profile).returns(c) |
| 353 | parent = fast_create(Folder, :profile_id => c.id) | 342 | parent = fast_create(Folder, :profile_id => c.id) |
| 354 | t = SuggestArticle.create!(:article => {:name => 'test name', :abstract => 'test abstract', :body => 'test body', :parent_id => parent.id}, :name => 'some name', :email => 'test@localhost.com', :target => c) | 343 | t = SuggestArticle.create!(:article => {:name => 'test name', :abstract => 'test abstract', :body => 'test body', :parent_id => parent.id}, :name => 'some name', :email => 'test@localhost.com', :target => c) |
| @@ -360,7 +349,7 @@ class TasksControllerTest < ActionController::TestCase | @@ -360,7 +349,7 @@ class TasksControllerTest < ActionController::TestCase | ||
| 360 | should "not display name from article suggestion when requestor was setted" do | 349 | should "not display name from article suggestion when requestor was setted" do |
| 361 | Task.destroy_all | 350 | Task.destroy_all |
| 362 | c = fast_create(Community) | 351 | c = fast_create(Community) |
| 363 | - c.add_admin profile | 352 | + c.add_admin person |
| 364 | @controller.stubs(:profile).returns(c) | 353 | @controller.stubs(:profile).returns(c) |
| 365 | t = SuggestArticle.create!(:article => {:name => 'test name', :abstract => 'test abstract', :body => 'test body'}, :requestor => fast_create(Person), :target => c) | 354 | t = SuggestArticle.create!(:article => {:name => 'test name', :abstract => 'test abstract', :body => 'test body'}, :requestor => fast_create(Person), :target => c) |
| 366 | 355 | ||
| @@ -376,7 +365,7 @@ class TasksControllerTest < ActionController::TestCase | @@ -376,7 +365,7 @@ class TasksControllerTest < ActionController::TestCase | ||
| 376 | 365 | ||
| 377 | should 'close create enterprise if trying to cancel even if there is already an existing identifier' do | 366 | should 'close create enterprise if trying to cancel even if there is already an existing identifier' do |
| 378 | identifier = "common-identifier" | 367 | identifier = "common-identifier" |
| 379 | - task = CreateEnterprise.create!(:identifier => identifier, :name => identifier, :requestor => profile, :target => profile) | 368 | + task = CreateEnterprise.create!(:identifier => identifier, :name => identifier, :requestor => person, :target => person) |
| 380 | fast_create(Profile, :identifier => identifier) | 369 | fast_create(Profile, :identifier => identifier) |
| 381 | 370 | ||
| 382 | assert_nothing_raised do | 371 | assert_nothing_raised do |
| @@ -392,9 +381,9 @@ class TasksControllerTest < ActionController::TestCase | @@ -392,9 +381,9 @@ class TasksControllerTest < ActionController::TestCase | ||
| 392 | class FeedDog < Task; end | 381 | class FeedDog < Task; end |
| 393 | Task.stubs(:per_page).returns(3) | 382 | Task.stubs(:per_page).returns(3) |
| 394 | requestor = fast_create(Person) | 383 | requestor = fast_create(Person) |
| 395 | - t1 = CleanHouse.create!(:requestor => requestor, :target => profile) | ||
| 396 | - t2 = CleanHouse.create!(:requestor => requestor, :target => profile) | ||
| 397 | - t3 = FeedDog.create!(:requestor => requestor, :target => profile) | 384 | + t1 = CleanHouse.create!(:requestor => requestor, :target => person) |
| 385 | + t2 = CleanHouse.create!(:requestor => requestor, :target => person) | ||
| 386 | + t3 = FeedDog.create!(:requestor => requestor, :target => person) | ||
| 398 | 387 | ||
| 399 | get :index, :filter_type => t1.type | 388 | get :index, :filter_type => t1.type |
| 400 | 389 | ||
| @@ -414,9 +403,9 @@ class TasksControllerTest < ActionController::TestCase | @@ -414,9 +403,9 @@ class TasksControllerTest < ActionController::TestCase | ||
| 414 | class FeedDog < Task; end | 403 | class FeedDog < Task; end |
| 415 | Task.stubs(:per_page).returns(3) | 404 | Task.stubs(:per_page).returns(3) |
| 416 | requestor = fast_create(Person) | 405 | requestor = fast_create(Person) |
| 417 | - t1 = CleanHouse.create!(:requestor => requestor, :target => profile, :data => {:name => 'Task Test'}) | ||
| 418 | - t2 = CleanHouse.create!(:requestor => requestor, :target => profile) | ||
| 419 | - t3 = FeedDog.create!(:requestor => requestor, :target => profile) | 406 | + t1 = CleanHouse.create!(:requestor => requestor, :target => person, :data => {:name => 'Task Test'}) |
| 407 | + t2 = CleanHouse.create!(:requestor => requestor, :target => person) | ||
| 408 | + t3 = FeedDog.create!(:requestor => requestor, :target => person) | ||
| 420 | 409 | ||
| 421 | get :index, :filter_type => t1.type, :filter_text => 'test' | 410 | get :index, :filter_type => t1.type, :filter_text => 'test' |
| 422 | 411 | ||
| @@ -435,11 +424,11 @@ class TasksControllerTest < ActionController::TestCase | @@ -435,11 +424,11 @@ class TasksControllerTest < ActionController::TestCase | ||
| 435 | 424 | ||
| 436 | requestor = fast_create(Person) | 425 | requestor = fast_create(Person) |
| 437 | 426 | ||
| 438 | - task_one = Task.create!(:requestor => requestor, :target => profile, :data => {:name => 'Task Test'}) | ||
| 439 | - task_two = Task.create!(:requestor => requestor, :target => profile, :data => {:name => 'Another Task'}) | 427 | + task_one = Task.create!(:requestor => requestor, :target => person, :data => {:name => 'Task Test'}) |
| 428 | + task_two = Task.create!(:requestor => requestor, :target => person, :data => {:name => 'Another Task'}) | ||
| 440 | 429 | ||
| 441 | - profile.tag(task_one, with: 'noosfero,test', on: :tags) | ||
| 442 | - profile.tag(task_two, with: 'test', on: :tags) | 430 | + person.tag(task_one, with: 'noosfero,test', on: :tags) |
| 431 | + person.tag(task_two, with: 'test', on: :tags) | ||
| 443 | 432 | ||
| 444 | get :index, :filter_tags => 'noosfero' | 433 | get :index, :filter_tags => 'noosfero' |
| 445 | 434 | ||
| @@ -449,11 +438,11 @@ class TasksControllerTest < ActionController::TestCase | @@ -449,11 +438,11 @@ class TasksControllerTest < ActionController::TestCase | ||
| 449 | 438 | ||
| 450 | should 'return tasks ordered accordingly and limited by pages' do | 439 | should 'return tasks ordered accordingly and limited by pages' do |
| 451 | time = Time.now | 440 | time = Time.now |
| 452 | - person = fast_create(Person) | ||
| 453 | - t1 = create(Task, :status => Task::Status::ACTIVE, :target => profile, :requestor => person, :created_at => time) | ||
| 454 | - t2 = create(Task, :status => Task::Status::ACTIVE, :target => profile, :requestor => person, :created_at => time + 1.second) | ||
| 455 | - t3 = create(Task, :status => Task::Status::ACTIVE, :target => profile, :requestor => person, :created_at => time + 2.seconds) | ||
| 456 | - t4 = create(Task, :status => Task::Status::ACTIVE, :target => profile, :requestor => person, :created_at => time + 3.seconds) | 441 | + requestor = fast_create(Person) |
| 442 | + t1 = create(Task, :status => Task::Status::ACTIVE, :target => person, :requestor => requestor, :created_at => time) | ||
| 443 | + t2 = create(Task, :status => Task::Status::ACTIVE, :target => person, :requestor => requestor, :created_at => time + 1.second) | ||
| 444 | + t3 = create(Task, :status => Task::Status::ACTIVE, :target => person, :requestor => requestor, :created_at => time + 2.seconds) | ||
| 445 | + t4 = create(Task, :status => Task::Status::ACTIVE, :target => person, :requestor => requestor, :created_at => time + 3.seconds) | ||
| 457 | 446 | ||
| 458 | Task.stubs(:per_page).returns(2) | 447 | Task.stubs(:per_page).returns(2) |
| 459 | 448 | ||
| @@ -469,9 +458,9 @@ class TasksControllerTest < ActionController::TestCase | @@ -469,9 +458,9 @@ class TasksControllerTest < ActionController::TestCase | ||
| 469 | Task.stubs(:per_page).returns(3) | 458 | Task.stubs(:per_page).returns(3) |
| 470 | requestor = fast_create(Person) | 459 | requestor = fast_create(Person) |
| 471 | responsible = fast_create(Person) | 460 | responsible = fast_create(Person) |
| 472 | - t1 = Task.create!(:requestor => requestor, :target => profile, :responsible => responsible) | ||
| 473 | - t2 = Task.create!(:requestor => requestor, :target => profile, :responsible => responsible) | ||
| 474 | - t3 = Task.create!(:requestor => requestor, :target => profile) | 461 | + t1 = Task.create!(:requestor => requestor, :target => person, :responsible => responsible) |
| 462 | + t2 = Task.create!(:requestor => requestor, :target => person, :responsible => responsible) | ||
| 463 | + t3 = Task.create!(:requestor => requestor, :target => person) | ||
| 475 | 464 | ||
| 476 | get :index, :filter_responsible => responsible.id | 465 | get :index, :filter_responsible => responsible.id |
| 477 | 466 | ||
| @@ -661,4 +650,25 @@ class TasksControllerTest < ActionController::TestCase | @@ -661,4 +650,25 @@ class TasksControllerTest < ActionController::TestCase | ||
| 661 | assert_select ".task_responsible .value" | 650 | assert_select ".task_responsible .value" |
| 662 | end | 651 | end |
| 663 | 652 | ||
| 653 | + should 'save task tags' do | ||
| 654 | + requestor = fast_create(Person) | ||
| 655 | + | ||
| 656 | + task_one = Task.create!(:requestor => requestor, :target => person, :data => {:name => 'Task Test'}) | ||
| 657 | + post :save_tags, :task_id => task_one.id, :tag_list => 'test' | ||
| 658 | + | ||
| 659 | + assert_includes task_one.tags_from(nil), 'test' | ||
| 660 | + end | ||
| 661 | + | ||
| 662 | + should 'tag attribution in one task not affect another' do | ||
| 663 | + requestor = fast_create(Person) | ||
| 664 | + | ||
| 665 | + task_one = Task.create!(:requestor => requestor, :target => person, :data => {:name => 'Task Test'}) | ||
| 666 | + task_two = Task.create!(:requestor => requestor, :target => person, :data => {:name => 'Another Task'}) | ||
| 667 | + | ||
| 668 | + post :save_tags, :task_id => task_one.id, :tag_list => 'noosfero,test' | ||
| 669 | + post :save_tags, :task_id => task_two.id, :tag_list => 'test' | ||
| 670 | + | ||
| 671 | + assert_not_includes task_two.tags_from(nil), 'noosfero' | ||
| 672 | + end | ||
| 673 | + | ||
| 664 | end | 674 | end |