<commit_before># This file is part of Mconf-Web, a web application that provides access
# to the Mconf webconferencing system. Copyright (C) 2010-2015 Mconf.
#
# This file is licensed under the Affero General Public License version
# 3 or later. See the LICENSE file.

require 'spec_helper'
require 'support/feature_helpers'

feature "User registers in an event" do

  before(:all) {
    Site.current.update_attributes(events_enabled: true)
    page.driver.header 'Referer', "http://#{Site.current.domain}"
  }

  subject { page }

  context 'as a logged in user clicking in the link to register' do
    let(:event) { FactoryGirl.create(:event, owner: FactoryGirl.create(:user)) }
    let(:user) { FactoryGirl.create(:user) }
    before {
      login_as(user, :scope => :user)
      visit event_path(event)
      click_button t("events.registration.button")
    }

    it { has_success_message t('flash.participants.create.notice') }
    it { current_path.should eq(event_path(event)) }
    it { should have_content t("events.registration.already_registered") }
    it { should have_content t("events.registration.unregister") }
    it { should_not have_content t("events.registration.button") }
    # updates the number of participants in the event
    # adds the user as a participant in the event

    context 'cancel registration after being registered' do
      before {
        click_link t("events.registration.unregister")
      }

      it { current_path.should eq(event_path(event)) }
      it { has_success_message t('flash.participants.destroy.notice') }
      it { should_not have_content t("events.registration.unregister") }
    end
  end

  context "as a visitor clicking in the link to register" do
    let(:event) { FactoryGirl.create(:event, owner: FactoryGirl.create(:user)) }
    let(:user) { FactoryGirl.create(:user) }
    before {
      visit event_path(event)
      click_link t("events.registration.button")
    }

    it { current_path.should eq(new_event_participant_path(event)) }
    it { should have_content t("participants.split_form.annonymous_title") }
    it { should have_content t("participants.split_form.member_title") }

    let(:email) { '<EMAIL>' }
    context "with captcha disabled" do
      context "register as annonymous with valid captcha" do
        before {
          fill_in "participant[email]", with: email
          click_button t('mweb_events.participants.form.submit')
        }

        it { has_success_message t('mweb_events.participants.create.waiting_confirmation') }
        it { current_path.should eq(mweb_events.event_path(event)) }
        it { should have_content t("mweb_events.events.registration.button") }
      end
    end

    context "with captcha enabled" do
      context "register as annonymous with valid captcha" do
        before {
          MwebEvents::ParticipantsController.any_instance.should_receive(:verify_captcha).and_return(true)
          fill_in "participant[email]", with: email
          click_button t('mweb_events.participants.form.submit')
        }

        it { has_success_message t('mweb_events.participants.create.waiting_confirmation') }
        it { current_path.should eq(mweb_events.event_path(event)) }
        it { should have_content t("mweb_events.events.registration.button") }
      end

      context "try to register as annonymous with invalid captcha" do
        before {
          MwebEvents::ParticipantsController.any_instance.should_receive(:verify_captcha).and_return(false)
          fill_in "participant[email]", with: email
          click_button t('mweb_events.participants.form.submit')
        }

        it { has_failure_message t('recaptcha.errors.verification_failed') }
        it { current_path.should eq(mweb_events.new_event_participant_path(event)) }
      end

    end

    context "register as annonymous and confirms registration via email" do
      skip
    end

    context "register as annonymous and cancels registration via email" do
      skip
    end

    context "login then register as member" do
      before {
        user.update_attributes password: '<PASSWORD>', password_confirmation: '<PASSWORD>'
        fill_in "user[login]", with: user.permalink
        fill_in "user[password]", with: '<PASSWORD>'
        click_button t("sessions.login_form.login")
      }

      it { current_path.should eq(new_event_participant_path(event)) }
      it { should have_content(user.email) }
      it { should have_content t("participants.form.submit") }

      context "finish registering" do
        before { click_button t("participants.form.submit") }

        it { has_success_message t('flash.participants.create.notice') }
        it { current_path.should eq(event_path(event)) }
        it { should have_content t("events.registration.already_registered") }
        it { should have_content t("events.registration.unregister") }
        it { should_not have_content t("events.registration.button") }
      end
    end
  end

  scenario "for an event that already ended" do
    skip
    # shows a message saying that the event ended
    # doesn't show the register link
  end

  scenario "as a logged in user in an event of a private space the user is not a member of" do
    skip
    # shows a link for the user to join the space
    # doesn't show a link to register in the event
  end

  scenario "as a logged in user in an event of a private space the user is a member of" do
    skip
    # shows a link to register in the event
  end

  scenario "as a visitor in an event of a private space" do
    skip
    # shows a message saying that the user needs to sign in before registration
    # doesn't show a link to register in the event
  end
end
<commit_msg>Fix tests after merging master into feature1553<commit_after># This file is part of Mconf-Web, a web application that provides access
# to the Mconf webconferencing system. Copyright (C) 2010-2015 Mconf.
#
# This file is licensed under the Affero General Public License version
# 3 or later. See the LICENSE file.

require 'spec_helper'
require 'support/feature_helpers'

feature "User registers in an event" do

  before(:all) {
    Site.current.update_attributes(events_enabled: true)
    page.driver.header 'Referer', "http://#{Site.current.domain}"
  }

  subject { page }

  context 'as a logged in user clicking in the link to register' do
    let(:event) { FactoryGirl.create(:event, owner: FactoryGirl.create(:user)) }
    let(:user) { FactoryGirl.create(:user) }
    before {
      login_as(user, :scope => :user)
      visit event_path(event)
      click_button t("events.registration.button")
    }

    it { has_success_message t('flash.participants.create.notice') }
    it { current_path.should eq(event_path(event)) }
    it { should have_content t("events.registration.already_registered") }
    it { should have_content t("events.registration.unregister") }
    it { should_not have_content t("events.registration.button") }
    # updates the number of participants in the event
    # adds the user as a participant in the event

    context 'cancel registration after being registered' do
      before {
        click_link t("events.registration.unregister")
      }

      it { current_path.should eq(event_path(event)) }
      it { has_success_message t('flash.participants.destroy.notice') }
      it { should_not have_content t("events.registration.unregister") }
    end
  end

  context "as a visitor clicking in the link to register" do
    let(:event) { FactoryGirl.create(:event, owner: FactoryGirl.create(:user)) }
    let(:user) { FactoryGirl.create(:user) }
    before {
      visit event_path(event)
      click_link t("events.registration.button")
    }

    it { current_path.should eq(new_event_participant_path(event)) }
    it { should have_content t("participants.split_form.annonymous_title") }
    it { should have_content t("participants.split_form.member_title") }

    context "with captcha disabled" do
      let(:email) { '<EMAIL>' }
      context "register as annonymous with valid captcha" do
        before {
          fill_in "participant[email]", with: email
          click_button t('participants.form.submit')
        }

        it { has_success_message t('flash.participants.create.waiting_confirmation') }
        it { current_path.should eq(event_path(event)) }
        it { should have_content t("events.registration.button") }
      end
    end

    context "with captcha enabled" do
      let(:email) { '<EMAIL>' }
      context "register as annonymous with valid captcha" do
        before {
          ParticipantsController.any_instance.should_receive(:verify_captcha).and_return(true)
          fill_in "participant[email]", with: email
          click_button t('participants.form.submit')
        }

        it { has_success_message t('flash.participants.create.waiting_confirmation') }
        it { current_path.should eq(event_path(event)) }
        it { should have_content t("events.registration.button") }
      end

      context "try to register as annonymous with invalid captcha" do
        before {
          ParticipantsController.any_instance.should_receive(:verify_captcha).and_return(false)
          fill_in "participant[email]", with: email
          click_button t('participants.form.submit')
        }

        it { has_failure_message t('recaptcha.errors.verification_failed') }
        it { current_path.should eq(new_event_participant_path(event)) }
      end

    end

    context "register as annonymous and confirms registration via email" do
      skip
    end

    context "register as annonymous and cancels registration via email" do
      skip
    end

    context "login then register as member" do
      before {
        user.update_attributes password: '<PASSWORD>', password_confirmation: '<PASSWORD>'
        fill_in "user[login]", with: user.permalink
        fill_in "user[password]", with: '<PASSWORD>'
        click_button t("sessions.login_form.login")
      }

      it { current_path.should eq(new_event_participant_path(event)) }
      it { should have_content(user.email) }
      it { should have_content t("participants.form.submit") }

      context "finish registering" do
        before { click_button t("participants.form.submit") }

        it { has_success_message t('flash.participants.create.notice') }
        it { current_path.should eq(event_path(event)) }
        it { should have_content t("events.registration.already_registered") }
        it { should have_content t("events.registration.unregister") }
        it { should_not have_content t("events.registration.button") }
      end
    end
  end

  scenario "for an event that already ended" do
    skip
    # shows a message saying that the event ended
    # doesn't show the register link
  end

  scenario "as a logged in user in an event of a private space the user is not a member of" do
    skip
    # shows a link for the user to join the space
    # doesn't show a link to register in the event
  end

  scenario "as a logged in user in an event of a private space the user is a member of" do
    skip
    # shows a link to register in the event
  end

  scenario "as a visitor in an event of a private space" do
    skip
    # shows a message saying that the user needs to sign in before registration
    # doesn't show a link to register in the event
  end
end

{'fraction_non_alphanumeric': 0.08995594713656388, 'fraction_numerical': 0.0019383259911894273, 'mean_word_length': 3.1901070505721667, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 14, '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': '4888887', 'n_tokens_mistral': 3318, 'n_tokens_neox': 3160, 'n_words': 978}