require 'spec_helper'

describe 'visit the index page for my groups' do
  it 'should see a table with all my groups' do
    # TODO: only groups that belong to te customer are displayed in
    # this page, not sure if we should display the groups which the
    # customer is a member.
    customer = create :customer
    # Group owned by the customer
    group1 = create :group, customer: customer

    # Group witn invitation accepted
    group2 = create :group
    create :group_membership, group: group2, customer: customer, status: 'accepted'
    # Group with invitation pending
    group3 = create :group
    create :group_membership, group: group3, customer: customer
    # Group without invitation
    group4 = create :group

    login_as_user customer
    click_link 'Get the Scoop'
    click_link 'Discussions'
    current_path.should eq customer_groups_path
    within '#groups_index'do
      page.should have_content group1.name
      page.should have_content group2.name
      page.should_not have_content group3.name
      page.should_not have_content group4.name
    end
  end
end
