<commit_before>require 'test_helper'

class LogPublishingTest < ActionController::TestCase

  tests DataFilesController

  fixtures :all

  include AuthenticatedTestHelper

  def setup
    login_as(:datafile_owner)
    @object=data_files(:picture)
  end

  test 'log when creating the public item' do
    @controller = SopsController.new()
    sop_params = valid_sop
    sop_params[:projects] = [projects(:three)] #this project has no gatekeeper
    assert_difference ('ResourcePublishLog.count') do
      post :create, :sop => sop_params, :sharing => public_sharing
    end
    publish_log = ResourcePublishLog.find(:last)
    assert_equal ResourcePublishLog::PUBLISHED, publish_log.publish_state.to_i
    sop = assigns(:sop)
    assert_equal sop, publish_log.resource
    assert_equal sop.contributor, publish_log.culprit
  end

  test 'log when creating item and request publish it' do
    @controller = SopsController.new()
    assert_difference ('ResourcePublishLog.count') do
      post :create, :sop => valid_sop, :sharing => {:sharing_scope => Policy::EVERYONE, "access_type_#{Policy::EVERYONE}" => Policy::VISIBLE}
    end
    publish_log = ResourcePublishLog.find(:last)
    assert_equal ResourcePublishLog::WAITING_FOR_APPROVAL, publish_log.publish_state.to_i
    sop = assigns(:sop)
    assert_equal sop, publish_log.resource
    assert_equal sop.contributor, publish_log.culprit
  end<commit_msg>fix project_ids for a test in logpublishingtest<commit_after>require 'test_helper'

class LogPublishingTest < ActionController::TestCase

  tests DataFilesController

  fixtures :all

  include AuthenticatedTestHelper

  def setup
    login_as(:datafile_owner)
    @object=data_files(:picture)
  end

  test 'log when creating the public item' do
    @controller = SopsController.new()
    sop_params = valid_sop
    sop_params[:project_ids] = [projects(:three).id] #this project has no gatekeeper
    assert_difference ('ResourcePublishLog.count') do
      post :create, :sop => sop_params, :sharing => public_sharing
    end
    publish_log = ResourcePublishLog.find(:last)
    assert_equal ResourcePublishLog::PUBLISHED, publish_log.publish_state.to_i
    sop = assigns(:sop)
    assert_equal sop, publish_log.resource
    assert_equal sop.contributor, publish_log.culprit
  end

  test 'log when creating item and request publish it' do
    @controller = SopsController.new()
    assert_difference ('ResourcePublishLog.count') do
      post :create, :sop => valid_sop, :sharing => {:sharing_scope => Policy::EVERYONE, "access_type_#{Policy::EVERYONE}" => Policy::VISIBLE}
    end
    publish_log = ResourcePublishLog.find(:last)
    assert_equal ResourcePublishLog::WAITING_FOR_APPROVAL, publish_log.publish_state.to_i
    sop = assigns(:sop)
    assert_equal sop, publish_log.resource
    assert_equal sop.contributor, publish_log.culprit
  end
{'fraction_non_alphanumeric': 0.08922323303009097, 'fraction_numerical': 0.0, 'mean_word_length': 4.740963855421687, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3625495', 'n_tokens_mistral': 898, 'n_tokens_neox': 865, 'n_words': 201}