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

class Groups::MembershipsControllerTest < ActionController::TestCase

  def setup
    @user  = FactoryGirl.create(:user)
    @group  = FactoryGirl.create(:group)
    @group.add_user!(@user)
  end

  def test_index
    login_as @user
    assert_permission :may_list_memberships? do
      get :index, :group_id => @group.to_param
    end
    assert_response :success
  end

  def test_destroy
    @council = FactoryGirl.create(:council)
    @group.add_council! @council
    @council.add_user! @user
    other_user  = FactoryGirl.create(:user)
    @group.add_user! other_user
    membership = @group.memberships.find_by_user_id(other_user.id)
    login_as @user
    assert_permission :may_destroy_membership? do
      delete :destroy, :group_id => @group.to_param, :id => membership.id
    end
    assert_response :success
  end

end<commit_msg>Use the committee factory to create councils.<commit_after>require File.dirname(__FILE__) + '/../../test_helper'

class Groups::MembershipsControllerTest < ActionController::TestCase

  def setup
    @user  = FactoryGirl.create(:user)
    @group  = FactoryGirl.create(:group)
    @group.add_user!(@user)
  end

  def test_index
    login_as @user
    assert_permission :may_list_memberships? do
      get :index, :group_id => @group.to_param
    end
    assert_response :success
  end

  def test_destroy
    @council = FactoryGirl.create(:committee)
    @group.add_council! @council
    @council.add_user! @user
    other_user  = FactoryGirl.create(:user)
    @group.add_user! other_user
    membership = @group.memberships.find_by_user_id(other_user.id)
    login_as @user
    assert_permission :may_destroy_membership? do
      delete :destroy, :group_id => @group.to_param, :id => membership.id
    end
    assert_response :success
  end

end
{'fraction_non_alphanumeric': 0.10279870828848224, 'fraction_numerical': 0.0, 'mean_word_length': 3.7912371134020617, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '5391459', 'n_tokens_mistral': 628, 'n_tokens_neox': 595, 'n_words': 123}