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

module RedmineCharts
describe ConditionsUtils do
  before(:all) do
    @utils = RedmineCharts::ConditionsUtils
    @types = @utils.types
  end

  it "should return project_its_subprojects_ids" do
    @utils.project_and_its_children_ids(15041).should == [15041,15042]
  end

  it "should return conditions_types" do
    @utils.types.should == [ :issue_ids, :project_ids, :user_ids, :category_ids, :status_ids, :activity_ids, :fixed_version_ids, :tracker_ids, :priority_ids, :author_ids, :assigned_to_ids ]
  end

  it "should return_proper_conditions" do
    project = Project.find(15041)
    options = @utils.to_options(project, @types)

    options[:user_ids] = options[:user_ids].select { |u| u[1] != 9 }
    options[:assigned_to_ids] = options[:assigned_to_ids].select { |u| u[1] != 9 }
    options[:author_ids] = options[:author_ids].select { |u| u[1] != 9 }

    options[:issue_ids].should be_nil
    options[:project_ids].should == [["Project1", 15041], ["Project2", 15042]]
    options[:user_ids].should == [["Redmine Admin", 15041]]
    options[:assigned_to_ids].should == [["Redmine Admin", 15041]]
    options[:author_ids].should == [["Redmine Admin", 15041]]
    options[:activity_ids].should == [["Design", 8], ["Development", 9]]
    options[:category_ids].should == [["Project1 - Category1", 15041], ["Project1 - Category2", 15042], ["Project2 - Category3", 15043]]
    options[:fixed_version_ids].should == [["Project1 - 1.0", 15041], ["Project1 - 2.0", 15042]]
    options[:tracker_ids].should == [["Bug", 1], ["Feature", 2], ["Support", 3]]
    options[:priority_ids].should == [["High", 5], ["Immediate", 7], ["Low", 3], ["Normal", 4], ["Urgent", 6]]
    options[:status_ids].should == [["Assigned", 2], ["Closed", 5], ["Feedback", 4], ["New", 1], ["Rejected", 6], ["Resolved", 3]]
  end

  it "should set project_ids if not provided in params" do
    conditions = @utils.from_params(@types, 15041, {})
    conditions[:project_ids].should == [15041, 15042]
  end

  it "should set project_ids if provided empty project in params" do
    conditions = @utils.from_params(@types, 15041, {:project_ids => []})
    conditions[:project_ids].should == [15041, 15042]
  end

  it "should set project_ids if provided wronghin params" do
    conditions = @utils.from_params(@types, 15041, {:project_ids => [0, nil, 15041, 15043, 15099],})
    conditions[:project_ids].should == [15041, 15043]
  end

  it "should read project_ids from params" do
    conditions = @utils.from_params(@types, 15041, {:project_ids => [15041, 15042, 15043]})
    conditions[:project_ids].should == [15041,15042,15043]<commit_msg>options should need more user.<commit_after>require File.dirname(__FILE__) + '/../spec_helper'

module RedmineCharts
describe ConditionsUtils do
  before(:all) do
    @utils = RedmineCharts::ConditionsUtils
    @types = @utils.types
  end

  it "should return project_its_subprojects_ids" do
    @utils.project_and_its_children_ids(15041).should == [15041,15042]
  end

  it "should return conditions_types" do
    @utils.types.should == [ :issue_ids, :project_ids, :user_ids, :category_ids, :status_ids, :activity_ids, :fixed_version_ids, :tracker_ids, :priority_ids, :author_ids, :assigned_to_ids ]
  end

  it "should return_proper_conditions" do
    project = Project.find(15041)
    options = @utils.to_options(project, @types)

    options[:user_ids] = options[:user_ids].select { |u| u[1] != 9 }
    options[:assigned_to_ids] = options[:assigned_to_ids].select { |u| u[1] != 9 }
    options[:author_ids] = options[:author_ids].select { |u| u[1] != 9 }

    options[:issue_ids].should be_nil
    options[:project_ids].should == [["Project1", 15041], ["Project2", 15042]]
    options[:user_ids].should == [["<NAME>", 15043], ["<NAME>", 15042], ["Redmine Admin", 15041]]
    options[:assigned_to_ids].should == [["<NAME>", 15043], ["<NAME>", 15042], ["Redmine Admin", 15041]]
    options[:author_ids].should == [["<NAME>", 15043], ["<NAME>", 15042], ["Redmine Admin", 15041]]
    options[:activity_ids].should == [["Design", 8], ["Development", 9]]
    options[:category_ids].should == [["Project1 - Category1", 15041], ["Project1 - Category2", 15042], ["Project2 - Category3", 15043]]
    options[:fixed_version_ids].should == [["Project1 - 1.0", 15041], ["Project1 - 2.0", 15042]]
    options[:tracker_ids].should == [["Bug", 1], ["Feature", 2], ["Support", 3]]
    options[:priority_ids].should == [["High", 5], ["Immediate", 7], ["Low", 3], ["Normal", 4], ["Urgent", 6]]
    options[:status_ids].should == [["Assigned", 2], ["Closed", 5], ["Feedback", 4], ["New", 1], ["Rejected", 6], ["Resolved", 3]]
  end

  it "should set project_ids if not provided in params" do
    conditions = @utils.from_params(@types, 15041, {})
    conditions[:project_ids].should == [15041, 15042]
  end

  it "should set project_ids if provided empty project in params" do
    conditions = @utils.from_params(@types, 15041, {:project_ids => []})
    conditions[:project_ids].should == [15041, 15042]
  end

  it "should set project_ids if provided wronghin params" do
    conditions = @utils.from_params(@types, 15041, {:project_ids => [0, nil, 15041, 15043, 15099],})
    conditions[:project_ids].should == [15041, 15043]
  end

  it "should read project_ids from params" do
    conditions = @utils.from_params(@types, 15041, {:project_ids => [15041, 15042, 15043]})
    conditions[:project_ids].should == [15041,15042,15043]
{'fraction_non_alphanumeric': 0.18028015281062398, 'fraction_numerical': 0.07895215572130253, 'mean_word_length': 4.95021645021645, 'pattern_counts': {'":': 0, '<': 9, '<?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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4918166', 'n_tokens_mistral': 2158, 'n_tokens_neox': 1807, 'n_words': 439}