<commit_before>require 'rails_helper'

RSpec.feature "SongPages", type: :feature do

  given(:song) { create(:song) }

  feature 'show song' do
    given(:user) { create(:user) }
    given(:open_song) { create(:song, status: :open) }
    given(:secret_song) { create(:song, status: :secret) }

    background do
      create(:playing, user: user, song: secret_song)
    end

    scenario 'A non-logged-in user can see the open song' do
      visit song_path(open_song)

      expect(page).to have_title(song.name)
      expect(page).to have_content(song.name)
      expect(page).to have_selector('.embed-responsive')
    end

    scenario 'A non-logged-in user cannot watch the closed song video' do
      visit song_path(song)

      expect(page).to have_title(song.name)
      expect(page).to have_content(song.name)
      expect(page).not_to have_selector('.embed-responsive')
    end

    scenario 'A logged-in user can see the closed song' do
      log_in_as user
      visit song_path(song)

      expect(page).to have_title(song.name)
      expect(page).to have_content(song.name)
      expect(page).to have_selector('.embed-responsive')
    end

    scenario 'A logged-in user cannot watch the secret song video' do
      log_in_as create(:user)
      visit song_path(secret_song)

      expect(page).to have_title(song.name)
      expect(page).not_to have_selector('.embed-responsive')
    end

    scenario 'A logged-in user user can edit the song he/she played', js: true do
      log_in_as user
      visit song_path(secret_song)
<commit_msg>Fix specs for song pages<commit_after>require 'rails_helper'

RSpec.feature 'SongPages', type: :feature do
  given(:song) { create(:song) }

  feature 'show song' do
    given(:user) { create(:user) }
    given(:open_song) { create(:song, status: :open) }
    given(:secret_song) { create(:song, status: :secret) }

    background do
      create(:playing, user: user, song: secret_song)
    end

    scenario 'A non-logged-in user can see the open song' do
      visit song_path(open_song)

      expect(page).to have_title(open_song.name)
      expect(page).to have_content(open_song.name)
      expect(page).to have_selector('.embed-responsive')
    end

    scenario 'A non-logged-in user cannot watch the closed song video' do
      visit song_path(song)

      expect(page).to have_title(song.name)
      expect(page).to have_content(song.name)
      expect(page).not_to have_selector('.embed-responsive')
    end

    scenario 'A logged-in user can see the closed song' do
      log_in_as user
      visit song_path(song)

      expect(page).to have_title(song.name)
      expect(page).to have_content(song.name)
      expect(page).to have_selector('.embed-responsive')
    end

    scenario 'A logged-in user cannot watch the secret song video' do
      log_in_as create(:user)
      visit song_path(secret_song)

      expect(page).to have_title(secret_song.name)
      expect(page).to have_content(secret_song.name)
      expect(page).not_to have_selector('.embed-responsive')
    end

    scenario 'A logged-in user user can edit the song he/she played', js: true do
      log_in_as user
      visit song_path(secret_song)

{'fraction_non_alphanumeric': 0.10790464240903387, 'fraction_numerical': 0.0, 'mean_word_length': 3.286290322580645, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3846128', 'n_tokens_mistral': 1059, 'n_tokens_neox': 991, 'n_words': 268}