<commit_before>require 'spec_helper'

feature "Flow Manager", js: true do
  let(:admin) do
    FactoryGirl.create :user, :admin, first_name: "Admin"
  end

  let(:author) do
    FactoryGirl.create :user, :admin, first_name: "Author"
  end

  let(:journal) { Journal.create! }

  let!(:paper1) do
    author.papers.create! short_title: 'foobar',
      title: 'Foo bar',
      submitted: true,
      journal: journal
  end

  let!(:paper2) do
    author.papers.create! short_title: 'bazqux',
      title: 'Baz Qux',
      submitted: true,
      journal: journal
  end

  def assign_tasks_to_user(paper, user, titles)
    paper.tasks.each { |t| t.update(assignee: user) if titles.include? t.title }
  end

  def complete_tasks(paper, titles)
    paper.tasks.each { |t| t.update(completed: true) if titles.include? t.title }
  end

  before do
    JournalRole.create! user: admin, journal: journal, admin: true
    sign_in_page = SignInPage.visit
    sign_in_page.sign_in admin.email
  end

  scenario "papers without assigned admins" do
    paper1.tasks.detect { |t| t.title == 'Assign Admin' }.update! assignee: admin<commit_msg>Resize window in flowmanager spec.<commit_after>require 'spec_helper'

feature "Flow Manager", js: true do
  let(:admin) do
    FactoryGirl.create :user, :admin, first_name: "Admin"
  end

  let(:author) do
    FactoryGirl.create :user, :admin, first_name: "Author"
  end

  let(:journal) { Journal.create! }

  let!(:paper1) do
    author.papers.create! short_title: 'foobar',
      title: 'Foo bar',
      submitted: true,
      journal: journal
  end

  let!(:paper2) do
    author.papers.create! short_title: 'bazqux',
      title: 'Baz Qux',
      submitted: true,
      journal: journal
  end

  def assign_tasks_to_user(paper, user, titles)
    paper.tasks.each { |t| t.update(assignee: user) if titles.include? t.title }
  end

  def complete_tasks(paper, titles)
    paper.tasks.each { |t| t.update(completed: true) if titles.include? t.title }
  end

  before do
    JournalRole.create! user: admin, journal: journal, admin: true
    page.driver.browser.manage.window.resize_to(1250,550)
    sign_in_page = SignInPage.visit
    sign_in_page.sign_in admin.email
  end

  scenario "papers without assigned admins" do
    paper1.tasks.detect { |t| t.title == 'Assign Admin' }.update! assignee: admin
{'fraction_non_alphanumeric': 0.11873124732104587, 'fraction_numerical': 0.005572224603514788, 'mean_word_length': 3.471264367816092, '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': '801421', 'n_tokens_mistral': 818, 'n_tokens_neox': 781, 'n_words': 210}