<commit_before>require 'rails_helper'

describe 'GroupShow' do
  feature 'User can leave Hangout', js: true do
    let!(:user) { User.create!(name: 'Matt', email: '<EMAIL>', password: 'password') }
    let!(:creator) { User.create!(name: 'Max', email: '<EMAIL>', password: 'password')}
    let!(:group) { Group.create!(name: "Test", admin_id: user.id) }
    let!(:hangout) {Hangout.create!(group_id: group.id, creator_id: creator.id)}

    before(:each) do
      group.members << creator
      group.members << user
      hangout.members << user

      visit '/'
      fill_in 'Email', with: '<EMAIL>'
      fill_in 'Password', with: 'password'
      click_on 'Log In'

      click_link('Test', match: :first)
    end

    it "shows leave hangout button" do
      expect(page).to have_content('Leave Hangout')
    end

    it "removes user from hangout and all Restaurants removed" do
      click_on 'Leave Hangout'
      expect(page).not_to have_content('Restaurants')
    end

    it "removes user from hangout and button goes back to join hangout" do
      click_on 'Leave Hangout'
      expect(page).to have_content('Join Hangout')
    end

    it "removes user from hangout and icon next to name is removed" do
      click_on 'Leave Hangout'
      user_div = page.find("div", :text => /\AMatt\z/)
      expect(user_div).not_to have_selector("button")
    end
  end
end<commit_msg>fix user leaves hangout test<commit_after>require 'rails_helper'

describe 'GroupShow' do
  feature 'User can leave Hangout', js: true do
    let!(:user) { User.create!(name: 'Matt', email: '<EMAIL>', password: 'password') }
    let!(:creator) { User.create!(name: 'Max', email: '<EMAIL>', password: 'password')}
    let!(:group) { Group.create!(name: "Test", admin_id: user.id) }
    let!(:hangout) {Hangout.create!(group_id: group.id, creator_id: creator.id)}

    before(:each) do
      group.members << creator
      group.members << user
      hangout.members << user

      visit '/'
      fill_in 'Email', with: '<EMAIL>'
      fill_in 'Password', with: 'password'
      click_on 'Log In'

      click_link('Test', match: :first)
    end

    it "shows leave hangout button" do
      expect(page).to have_content('Leave Hangout')
    end

    it "removes user from hangout and all Restaurants removed" do
      click_on 'Leave Hangout'
      expect(page).not_to have_content('Restaurants')
    end

    it "removes user from hangout and button goes back to create hangout" do
      click_on 'Leave Hangout'
      expect(page).to have_content('Create Hangout')
    end

    it "removes user from hangout and icon next to name is removed" do
      click_on 'Leave Hangout'
      user_div = page.find("div", :text => /\AMatt\z/)
      expect(user_div).not_to have_selector("button")
    end
  end
end
{'fraction_non_alphanumeric': 0.13051272857655075, 'fraction_numerical': 0.0, 'mean_word_length': 3.2465753424657535, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 11, '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': '3300940', 'n_tokens_mistral': 916, 'n_tokens_neox': 885, 'n_words': 267}