<commit_before>require File.expand_path(File.dirname(__FILE__) + '/../acceptance_helper')

feature "List", %q{
  In order to manage multiple studies I am preparing for submission
  As a contributor
  I want to view a list of my unsubmitted deposits
} do

  background do
    create_user 'Alice'
    create_user 'Bill'
    create_study 'First Study',  :owner => 'Alice'
    create_study 'Second Study', :owner => 'Alice'
    create_study 'Advanced Ham', :owner => 'Bill'
  end

  shared_examples_for "on the study index page" do
    path_should_be '/adapt/studies'
    page_heading_should_be 'Deposits'
  end

  scenario "Alice can see her deposits, but not Bill's" do
    login_as 'Alice'
    click_link 'View deposits'

    path_should_be '/adapt/studies'
    page_heading_should_be 'Deposits'
    page.should have_css("table tbody tr", :count => 2)

    creators = column_contents 'Created by'
    creators.should include 'Alice'
    creators.should_not include 'Bill'

    titles = column_contents 'Title'
    titles.should include 'First Study'
    titles.should include 'Second Study'
    titles.should_not include 'Advanced Ham'
  end

  scenario "Bill can see his deposits, but not Alice's" do
    login_as 'Bill'
    click_link 'View deposits'

    path_should_be '/adapt/studies'
    page_heading_should_be 'Deposits'
    page.should have_css("table tbody tr", :count => 1)

    creators = column_contents 'Created by'
    creators.should_not include 'Alice'
    creators.should include 'Bill'

    titles = column_contents 'Title'
    titles.should_not include 'First Study'
    titles.should_not include 'Second Study'
    titles.should include 'Advanced Ham'
  end

  def path_should_be(path)
    URI.parse(current_url).path.should == path
  end

  def page_heading_should_be(text)
    page.should have_css "#content > h1, article > h1", :text => text
  end

  def column_contents(name)
    data = page.find('table').all('tr').map do |row|
      row.all('th,td').map &:text
    end
    if n = data[0].index(name)
      (data.transpose)[n][1..-1].join('|')
    else
      ''
    end
  end
end
<commit_msg>Cleaned up the study index feature.<commit_after>require File.expand_path(File.dirname(__FILE__) + '/../acceptance_helper')

feature "List", %q{
  In order to manage multiple studies that I am preparing for submission
  As a contributor
  I want to view a list of my unsubmitted deposits
} do

  background do
    create_user 'Alice'
    create_user 'Bill'
    create_study 'First Study',  :owner => 'Alice'
    create_study 'Second Study', :owner => 'Alice'
    create_study 'Advanced Ham', :owner => 'Bill'
  end

  scenario "Alice can see her deposits, but not Bill's" do
    login_as 'Alice'
    click_link 'View deposits'

    path_should_be '/adapt/studies'
    page_heading_should_be 'Deposits'
    page.should have_css("table tbody tr", :count => 2)

    creators = column_contents 'Created by'
    creators.should include 'Alice'
    creators.should_not include 'Bill'

    titles = column_contents 'Title'
    titles.should include 'First Study'
    titles.should include 'Second Study'
    titles.should_not include 'Advanced Ham'
  end

  scenario "Bill can see his deposits, but not Alice's" do
    login_as 'Bill'
    click_link 'View deposits'

    path_should_be '/adapt/studies'
    page_heading_should_be 'Deposits'
    page.should have_css("table tbody tr", :count => 1)

    creators = column_contents 'Created by'
    creators.should_not include 'Alice'
    creators.should include 'Bill'

    titles = column_contents 'Title'
    titles.should_not include 'First Study'
    titles.should_not include 'Second Study'
    titles.should include 'Advanced Ham'
  end

  def path_should_be(path)
    URI.parse(current_url).path.should == path
  end

  def page_heading_should_be(text)
    page.should have_css "#content > h1, article > h1", :text => text
  end

  def column_contents(name)
    data = page.find('table').all('tr').map do |row|
      row.all('th,td').map &:text
    end
    if n = data[0].index(name)
      (data.transpose)[n][1..-1].join('|')
    else
      ''
    end
  end
end

{'fraction_non_alphanumeric': 0.10346498667312819, 'fraction_numerical': 0.003392294645020596, 'mean_word_length': 3.42443729903537, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '4423613', 'n_tokens_mistral': 1368, 'n_tokens_neox': 1326, 'n_words': 394}