Sha256: 9304153f8f4a8c3a5237d1bd417191f116aeda6cd710723a127f9514eaadcf10

Contents?: true

Size: 1.66 KB

Versions: 12

Compression:

Stored size: 1.66 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper' ))

module IntegrationTests
  class MembershipsTest < ActionController::IntegrationTest
    def setup
      super
      @site = use_site! 'site with pages'
    end

    test "when superuser creates a new user on the backend,
          the new user should have a membership to the page it was created on (fix for bug #288)" do
      login_as_superuser
      visit_new_user_form
      post_the_new_user_form
    end
    
    test "when superuser creates a new superuser on the backend the new superuser does not need to 
          be member of any site" do
      login_as_superuser
      visit_new_user_form
      post_the_new_user_form_for_superuser
    end
    
    def visit_new_user_form
      visit "/admin/sites/#{@site.id}/users/new"
      renders_template "admin/users/new"
    end
    
    def post_the_new_user_form
      fill_in :user_first_name, :with => 'John'
      fill_in :user_last_name,  :with => 'Doe'
      fill_in :user_email,      :with => 'memberships@test.org'
      fill_in :user_password,   :with => 'pass'
      click_button :save
      
      user = User.find_by_email('memberships@test.org')
      assert !user.memberships.blank?
    end
    
    def post_the_new_user_form_for_superuser
      fill_in :user_first_name, :with => 'John'
      fill_in :user_last_name,  :with => 'Superuser'
      fill_in :user_email,      :with => 'superusers.memberships@test.org'
      fill_in :user_password,   :with => 'pass'
      check   :role_superuser
      click_button :save
      
      user = User.find_by_email('superusers.memberships@test.org')
      assert user.memberships.empty?
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
adva-0.2.4 test/integration/memberships_test.rb
adva-0.2.3 test/integration/memberships_test.rb
adva-0.2.2 test/integration/memberships_test.rb
adva-0.2.1 test/integration/memberships_test.rb
adva-0.2.0 test/integration/memberships_test.rb
adva-0.1.4 test/integration/memberships_test.rb
adva-0.1.3 test/integration/memberships_test.rb
adva-0.1.2 test/integration/memberships_test.rb
adva-0.1.1 test/integration/memberships_test.rb
adva-0.1.0 test/integration/memberships_test.rb
adva_user-0.0.1 test/integration/memberships_test.rb
adva-0.0.1 adva_user/test/integration/memberships_test.rb