<commit_before>require 'spec_helper'

describe Forem::TopicsController do
  let(:visible_topic) { Factory(:topic) }
  let(:hidden_topic) { Factory(:topic, :hidden => true) }

  before do
    sign_in(:user, Factory(:user))
  end

  # Regression test for #122
  it "cannot subscribe to a hidden topic" do
    get :subscribe, :forum_id => hidden_topic.forum_id, :id => hidden_topic.id
    flash[:alert].should == "The topic you are looking for could not be found."
  end

end<commit_msg>Use stubbing in topics_controller_spec FOR SPEED<commit_after>require 'spec_helper'

describe Forem::TopicsController do

  before do
    sign_in(:user, Factory(:user))

    forum = stub_model(Forem::Forum)

    controller.should_receive(:authorize!).and_return(true)
    Forem::Forum.should_receive(:find).and_return(forum)
    forum.stub_chain("topics.visible.find").and_raise(ActiveRecord::RecordNotFound)
  end

  # Regression test for #122
  it "cannot subscribe to a hidden topic" do
    get :subscribe, :forum_id => 1, :id => 1
    flash[:alert].should == "The topic you are looking for could not be found."
  end

end
{'fraction_non_alphanumeric': 0.11541929666366095, 'fraction_numerical': 0.007213706041478809, 'mean_word_length': 4.577889447236181, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '4031061', 'n_tokens_mistral': 370, 'n_tokens_neox': 345, 'n_words': 99}