Commit 2ea458ec009812d65528b640b6ec729245feb934

Authored by Francisco Marcelo de Araújo Lima Júnior
1 parent 7b182226

add functional tests

plugins/community_hub/test/functional/community_hub_plugin_cms_controller_test.rb 0 → 100644
... ... @@ -0,0 +1,73 @@
  1 +require File.dirname(__FILE__) + '/../test_helper'
  2 +
  3 +class CmsController; def rescue_action(e) raise e end; end
  4 +
  5 +class CmsControllerTest < ActionController::TestCase
  6 +
  7 + def setup
  8 + @controller = CmsController.new
  9 + @request = ActionController::TestRequest.new
  10 + @response = ActionController::TestResponse.new
  11 +
  12 + user = create_user('testinguser')
  13 +
  14 + @environment = user.environment
  15 +
  16 + @community = Community.create!(
  17 + :name => 'Sample community',
  18 + :identifier => 'sample-community',
  19 + :environment => @environment
  20 + )
  21 +
  22 + @community.add_admin(user.person)
  23 +
  24 + @community.save!
  25 +
  26 + @hub = CommunityHubPlugin::Hub.new(
  27 + :abstract => 'abstract',
  28 + :body => 'body',
  29 + :name => 'test-hub',
  30 + :profile => @community,
  31 + :last_changed_by_id => user
  32 + )
  33 +
  34 + @hub.save!
  35 +
  36 + login_as(user.login)
  37 +
  38 + end
  39 +
  40 + should 'be able to edit hub settings' do
  41 + get :edit, :id => @hub.id, :profile => @community.identifier
  42 + assert_tag :tag => 'input', :attributes => { :id => 'article_name' }
  43 + assert_tag :tag => 'textarea', :attributes => { :id => 'article_body' }
  44 + assert_tag :tag => 'input', :attributes => { :id => 'article_twitter_enabled' }
  45 + assert_tag :tag => 'input', :attributes => { :id => 'article_twitter_hashtags' }
  46 + assert_tag :tag => 'input', :attributes => { :id => 'article_facebook_enabled' }
  47 + assert_tag :tag => 'input', :attributes => { :id => 'article_facebook_hashtag' }
  48 + assert_tag :tag => 'input', :attributes => { :id => 'article_facebook_access_token' }
  49 + end
  50 +
  51 + should 'be able to save hub' do
  52 + get :edit, :id => @hub.id, :profile => @community.identifier
  53 + post :edit, :id => @hub.id, :profile => @community.identifier, :article => {
  54 + :name => 'changed',
  55 + :body => 'changed',
  56 + :twitter_enabled => true,
  57 + :twitter_hashtags => 'changed',
  58 + :facebook_enabled => true,
  59 + :facebook_hashtag => 'changed',
  60 + :facebook_access_token => 'changed'
  61 + }
  62 + @hub.reload
  63 + assert_equal 'changed', @hub.name
  64 + assert_equal 'changed', @hub.body
  65 + assert_equal true, @hub.twitter_enabled
  66 + assert_equal 'changed', @hub.twitter_hashtags
  67 + assert_equal true, @hub.facebook_enabled
  68 + assert_equal 'changed', @hub.facebook_hashtag
  69 + assert_equal 'changed', @hub.facebook_access_token
  70 + end
  71 +
  72 +end
  73 +
... ...