<commit_before># encoding: UTF-8
require File.dirname(__FILE__) + "/../spec_helper"

describe "Profile page" do
  let(:user) { FactoryGirl.create :user }

  before do
    login_as user
    click_link "Profil"
  end

  it "should allow user to change name and email" do
    page.should have_content("Name")
    page.should have_content("E-Mail")

    fill_in "Name", with: "<NAME>"
    fill_in "E-Mail", with: "<EMAIL>"
    click_on "Speichern"

    page.should have_content("Profil gespeichert.")

    find_field('Name').value.should == '<NAME>'
    find_field('E-Mail').value.should == '<EMAIL>'
  end

  it "should raise error when user tries to update with empty name" do
    page.should have_content("Name")
    page.should have_content("E-Mail")

    fill_in "Name", with: ""
    fill_in "E-Mail", with: "<EMAIL>"
    click_on "Speichern"

    page.should have_content("muss ausgefüllt werden")
    find_field('Name').value.should == ''
    find_field('E-Mail').value.should == '<EMAIL>'
  end

  it "should allow user to add an identity" do
    click_link "Identität hinzufügen"

    expect { click_link "GitHub" }.to change { Identity.all.count }.by(1)

    Identity.last.provider.should == "github"

    current_path.should == user_path(user)
    page.should have_content("GitHub Identität hinzugefügt.")
  end

  it "should allow user to remove an identity", js: true do
    click_link "Identität hinzufügen"
    click_link "GitHub"

    expect { click_link "Twitter Identität entfernen" }.to change {
      Identity.all.count }.from(2).to(1)

    Identity.first.provider.should == "github"<commit_msg>Remove js flag from logout spec.<commit_after># encoding: UTF-8
require File.dirname(__FILE__) + "/../spec_helper"

describe "Profile page" do
  let(:user) { FactoryGirl.create :user }

  before do
    login_as user
    click_link "Profil"
  end

  it "should allow user to change name and email" do
    page.should have_content("Name")
    page.should have_content("E-Mail")

    fill_in "Name", with: "<NAME>"
    fill_in "E-Mail", with: "<EMAIL>"
    click_on "Speichern"

    page.should have_content("Profil gespeichert.")

    find_field('Name').value.should == '<NAME>'
    find_field('E-Mail').value.should == '<EMAIL>'
  end

  it "should raise error when user tries to update with empty name" do
    page.should have_content("Name")
    page.should have_content("E-Mail")

    fill_in "Name", with: ""
    fill_in "E-Mail", with: "<EMAIL>"
    click_on "Speichern"

    page.should have_content("muss ausgefüllt werden")
    find_field('Name').value.should == ''
    find_field('E-Mail').value.should == '<EMAIL>'
  end

  it "should allow user to add an identity" do
    click_link "Identität hinzufügen"

    expect { click_link "GitHub" }.to change { Identity.all.count }.by(1)

    Identity.last.provider.should == "github"

    current_path.should == user_path(user)
    page.should have_content("GitHub Identität hinzugefügt.")
  end

  it "should allow user to remove an identity" do
    click_link "Identität hinzufügen"
    click_link "GitHub"

    expect { click_link "Twitter Identität entfernen" }.to change {
      Identity.all.count }.from(2).to(1)

    Identity.first.provider.should == "github"
{'fraction_non_alphanumeric': 0.1309192200557103, 'fraction_numerical': 0.0024760136180748994, 'mean_word_length': 3.5585331452750353, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '5298839', 'n_tokens_mistral': 1096, 'n_tokens_neox': 1055, 'n_words': 284}