Commit 902adfb1c2855a737686bf6e2fa39227a7b1b4a2

Authored by Rodrigo Souto
1 parent f462e462

Fixing cms and invite controller tests

(ActionItem2313)
test/functional/cms_controller_test.rb
@@ -584,7 +584,8 @@ class CmsControllerTest < Test::Unit::TestCase @@ -584,7 +584,8 @@ class CmsControllerTest < Test::Unit::TestCase
584 should 'be able to add image with alignment' do 584 should 'be able to add image with alignment' do
585 post :new, :type => 'TinyMceArticle', :profile => profile.identifier, :article => { :name => 'image-alignment', :body => "the text of the article with image <img src='#' align='right'/> right align..." } 585 post :new, :type => 'TinyMceArticle', :profile => profile.identifier, :article => { :name => 'image-alignment', :body => "the text of the article with image <img src='#' align='right'/> right align..." }
586 saved = TinyMceArticle.find_by_name('image-alignment') 586 saved = TinyMceArticle.find_by_name('image-alignment')
587 - assert_match /<img src="#" align="right" \/>/, saved.body 587 + assert_match /<img.*src="#".*\/>/, saved.body
  588 + assert_match /<img.*align="right".*\/>/, saved.body
588 end 589 end
589 590
590 should 'not be able to add image with alignment when textile' do 591 should 'not be able to add image with alignment when textile' do
test/functional/invite_controller_test.rb
@@ -188,9 +188,10 @@ class InviteControllerTest &lt; ActionController::TestCase @@ -188,9 +188,10 @@ class InviteControllerTest &lt; ActionController::TestCase
188 should 'return hash as invitation data if contact list was fetched' do 188 should 'return hash as invitation data if contact list was fetched' do
189 contact_list = ContactList.create(:fetched => true) 189 contact_list = ContactList.create(:fetched => true)
190 get :invitation_data, :profile => profile.identifier, :contact_list => contact_list.id 190 get :invitation_data, :profile => profile.identifier, :contact_list => contact_list.id
  191 + hash = {'fetched' => true, 'contact_list' => contact_list.id, 'error' => nil}
191 192
192 assert_equal 'application/javascript', @response.content_type 193 assert_equal 'application/javascript', @response.content_type
193 - assert_equal "{\"fetched\": true, \"contact_list\": #{contact_list.id}, \"error\": null}", @response.body 194 + assert_equal hash, json_response
194 end 195 end
195 196
196 should 'render empty list of contacts' do 197 should 'render empty list of contacts' do
@@ -233,4 +234,11 @@ class InviteControllerTest &lt; ActionController::TestCase @@ -233,4 +234,11 @@ class InviteControllerTest &lt; ActionController::TestCase
233 assert_equal 'pt', Delayed::Job.first.payload_object.locale 234 assert_equal 'pt', Delayed::Job.first.payload_object.locale
234 end 235 end
235 236
  237 + private
  238 +
  239 + def json_response
  240 + ActiveSupport::JSON.decode @response.body
  241 + end
  242 +
  243 +
236 end 244 end