<commit_before>class DevelopmentController < ApplicationController
  include Development::DashboardHelper
  include Development::NintiesMoviesHelper

  before_filter :cleanup_database, except: [:last_email, :index, :accept_last_invitation]
  around_filter :ensure_testing_environment

  def index
    @routes = DevelopmentController.action_methods.select do |action|
      action.starts_with? 'setup'
    end
    render layout: false
  end

  def last_email
    @email = ActionMailer::Base.deliveries.last
    render layout: false
  end

  def accept_last_invitation
    InvitationService.redeem(Invitation.last, max)
    redirect_to(test_group)
  end

  def setup_dashboard
    sign_in patrick
    starred_proposal_discussion; proposal_discussion; starred_discussion
    recent_discussion; old_discussion; participating_discussion; muted_discussion; muted_group_discussion
    redirect_to dashboard_url
  end

  def setup_inbox
    sign_in patrick
    starred_discussion; recent_discussion group: another_test_group
    old_discussion; muted_discussion
    redirect_to inbox_url
  end

  def setup_new_group
    group = Group.new(name: 'Fresh group')
    StartGroupService.start_group(group)
    group.add_admin! patrick
    sign_in patrick
    redirect_to group_url(group)
  end

  def setup_group
    sign_in patrick
    test_group.add_member! emilio
    redirect_to group_url(test_group)
  end

  def setup_group_with_expired_legacy_trial
    sign_in jennifer
    GroupService.create(group: test_group, actor: patrick)
    test_group.update_attribute(:cohort_id, 3)
    redirect_to group_url(test_group)
  end

  def setup_group_with_expired_legacy_trial_admin
    sign_in patrick
    test_group.add_member! emilio
    test_group.update_attribute(:cohort_id, 3)
    ENV['TRIAL_EXPIRED_GROUP_IDS'] = test_group.id.to_s

    redirect_to group_url(test_group)
  end

  def setup_group_with_many_discussions
    sign_in patrick
    test_group.add_member! emilio
    50.times do
      discussion = FactoryGirl.build(:discussion,
                                     group: test_group,
                                     private: true,
                                     author: emilio)
      DiscussionService.create(discussion: discussion, actor: emilio)
    end
    redirect_to group_url(test_group)
  end

  def setup_group_on_trial_admin
    sign_in patrick
    group_on_trial = Group.new(name: 'Ghostbusters', is_visible_to_public: true)
    GroupService.create(group: group_on_trial, actor: patrick)
    group_on_trial.add_member! jennifer
    redirect_to group_url(group_on_trial)
  end

  def setup_group_on_trial
    sign_in jennifer
    GroupService.create(group: test_group, actor: patrick)
    redirect_to group_url(test_group)
  end

  def setup_group_with_expired_trial
    GroupService.create(group: test_group, actor: patrick)<commit_msg>Add discussion with many comments development route<commit_after>class DevelopmentController < ApplicationController
  include Development::DashboardHelper
  include Development::NintiesMoviesHelper

  before_filter :cleanup_database, except: [:last_email, :index, :accept_last_invitation]
  around_filter :ensure_testing_environment

  def index
    @routes = DevelopmentController.action_methods.select do |action|
      action.starts_with? 'setup'
    end
    render layout: false
  end

  def last_email
    @email = ActionMailer::Base.deliveries.last
    render layout: false
  end

  def accept_last_invitation
    InvitationService.redeem(Invitation.last, max)
    redirect_to(test_group)
  end

  def setup_dashboard
    sign_in patrick
    starred_proposal_discussion; proposal_discussion; starred_discussion
    recent_discussion; old_discussion; participating_discussion; muted_discussion; muted_group_discussion
    redirect_to dashboard_url
  end

  def setup_inbox
    sign_in patrick
    starred_discussion; recent_discussion group: another_test_group
    old_discussion; muted_discussion
    redirect_to inbox_url
  end

  def setup_new_group
    group = Group.new(name: 'Fresh group')
    StartGroupService.start_group(group)
    group.add_admin! patrick
    sign_in patrick
    redirect_to group_url(group)
  end

  def setup_group
    sign_in patrick
    test_group.add_member! emilio
    redirect_to group_url(test_group)
  end

  def setup_group_with_expired_legacy_trial
    sign_in jennifer
    GroupService.create(group: test_group, actor: patrick)
    test_group.update_attribute(:cohort_id, 3)
    redirect_to group_url(test_group)
  end

  def setup_group_with_expired_legacy_trial_admin
    sign_in patrick
    test_group.add_member! emilio
    test_group.update_attribute(:cohort_id, 3)
    ENV['TRIAL_EXPIRED_GROUP_IDS'] = test_group.id.to_s

    redirect_to group_url(test_group)
  end

  def setup_group_with_many_discussions
    sign_in patrick
    test_group.add_member! emilio
    50.times do
      discussion = FactoryGirl.build(:discussion,
                                     group: test_group,
                                     private: true,
                                     author: emilio)
      DiscussionService.create(discussion: discussion, actor: emilio)
    end
    redirect_to group_url(test_group)
  end

  def setup_discussion_with_many_comments
    test_group.add_member! emilio
    40.times do |i|
      comment = FactoryGirl.build(:comment, discussion: test_discussion, body: "#{i} bottles of beer on the wall")
      CommentService.create(comment: comment, actor: emilio)
    end
    redirect_to discussion_url(test_discussion, from: 5)
  end

  def setup_group_on_trial_admin
    sign_in patrick
    group_on_trial = Group.new(name: 'Ghostbusters', is_visible_to_public: true)
    GroupService.create(group: group_on_trial, actor: patrick)
    group_on_trial.add_member! jennifer
    redirect_to group_url(group_on_trial)
  end

  def setup_group_on_trial
    sign_in jennifer
    GroupService.create(group: test_group, actor: patrick)
    redirect_to group_url(test_group)
  end

  def setup_group_with_expired_trial
    GroupService.create(group: test_group, actor: patrick)
{'fraction_non_alphanumeric': 0.05561023622047244, 'fraction_numerical': 0.0018044619422572178, 'mean_word_length': 3.815955766192733, 'pattern_counts': {'":': 0, '<': 5, '<?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': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5312553', 'n_tokens_mistral': 1976, 'n_tokens_neox': 1859, 'n_words': 390}