<commit_before>require File.dirname(__FILE__) + '/../test_helper'

class PrivaciesControllerTest < ActionController::TestCase

  should "redirect to edit action" do
    get :show, {:group_id => groups(:college).id, :membership_id => memberships(:peter_in_college_group).id},
      {:logged_in_id => people(:peter).id}
    assert_redirected_to edit_group_membership_privacy_path(groups(:college), memberships(:peter_in_college_group))
    get :show, {:person_id => people(:peter).id}, {:logged_in_id => people(:peter).id}
    assert_redirected_to edit_person_privacy_path(people(:peter))
  end

  should "edit membership privacy" do
    get :edit, {:group_id => groups(:college).id, :membership_id => memberships(:peter_in_college_group).id},
      {:logged_in_id => people(:peter).id}
    assert_response :success
    assert_template 'edit_membership'
    post :update, {
      :group_id => groups(:college).id,
      :membership_id => memberships(:peter_in_college_group).id,
      :membership => {
        :share_address      => true,
        :share_mobile_phone => true,
        :share_home_phone   => true,
        :share_work_phone   => false,
        :share_fax          => false,
        :share_email        => true,
        :share_birthday     => false,
        :share_anniversary  => false }
      }, {:logged_in_id => people(:peter).id}
    assert assigns(:membership).errors.empty?
    assert_redirected_to edit_group_membership_privacy_path(groups(:college), memberships(:peter_in_college_group))
    assert  memberships(:peter_in_college_group).reload.share_address?
    assert  memberships(:peter_in_college_group).share_mobile_phone?
    assert  memberships(:peter_in_college_group).share_home_phone?
    assert !memberships(:peter_in_college_group).share_work_phone?<commit_msg>Rails 3 takes anchor into account in assert_redirected_to.<commit_after>require File.dirname(__FILE__) + '/../test_helper'

class PrivaciesControllerTest < ActionController::TestCase

  should "redirect to edit action" do
    get :show, {:group_id => groups(:college).id, :membership_id => memberships(:peter_in_college_group).id},
      {:logged_in_id => people(:peter).id}
    assert_redirected_to edit_group_membership_privacy_path(groups(:college), memberships(:peter_in_college_group))
    get :show, {:person_id => people(:peter).id}, {:logged_in_id => people(:peter).id}
    assert_redirected_to edit_person_privacy_path(people(:peter), :anchor => 'p3')
  end

  should "edit membership privacy" do
    get :edit, {:group_id => groups(:college).id, :membership_id => memberships(:peter_in_college_group).id},
      {:logged_in_id => people(:peter).id}
    assert_response :success
    assert_template 'edit_membership'
    post :update, {
      :group_id => groups(:college).id,
      :membership_id => memberships(:peter_in_college_group).id,
      :membership => {
        :share_address      => true,
        :share_mobile_phone => true,
        :share_home_phone   => true,
        :share_work_phone   => false,
        :share_fax          => false,
        :share_email        => true,
        :share_birthday     => false,
        :share_anniversary  => false }
      }, {:logged_in_id => people(:peter).id}
    assert assigns(:membership).errors.empty?
    assert_redirected_to edit_group_membership_privacy_path(groups(:college), memberships(:peter_in_college_group))
    assert  memberships(:peter_in_college_group).reload.share_address?
    assert  memberships(:peter_in_college_group).share_mobile_phone?
    assert  memberships(:peter_in_college_group).share_home_phone?
    assert !memberships(:peter_in_college_group).share_work_phone?
{'fraction_non_alphanumeric': 0.12191780821917808, 'fraction_numerical': 0.000547945205479452, 'mean_word_length': 4.384955752212389, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 44, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2225764', 'n_tokens_mistral': 1202, 'n_tokens_neox': 1178, 'n_words': 182}