cirandas.net

ref: master

plugins/google_analytics/test/functional/profile_editor_controller_test.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
require 'test_helper'

class ProfileEditorControllerTest < ActionController::TestCase

  def setup
    @controller = ProfileEditorController.new

    @profile = create_user('default_user').person
    login_as(@profile.identifier)
    Environment.default.enable_plugin(GoogleAnalyticsPlugin.name)
  end

  attr_accessor :profile

  should 'add extra fields to profile editor info and settings' do
    get :edit, :profile => profile.identifier
    assert_tag_in_string @response.body, :tag => 'label', :content => /Google Analytics/,  :attributes => { :for => 'profile_data_google_analytics_profile_id' }
    assert_tag_in_string @response.body, :tag => 'input', :attributes => { :id => 'profile_data_google_analytics_profile_id' }
  end

  should 'save code filled in on field' do
    post :edit, :profile => profile.identifier, :profile_data => {:google_analytics_profile_id => 12345678}
    assert_equal '12345678', Person.find(profile.id).google_analytics_profile_id
  end

end