Sha256: e3a3adc1d3899a0706f86cbf9eebb275d479091364913d20000494d28490da58

Contents?: true

Size: 1.36 KB

Versions: 2

Compression:

Stored size: 1.36 KB

Contents

require 'spec_helper'

describe "posts" do 
	
	before do
		@user = User.create!(:login => "some_guy")
		@topic = Forem::Topic.new(:subject => "First topic!", :user => @user)
		@topic.posts.build(:text => "First post!")
		@topic.save!
	end

	context "unauthenticated users" do
		before do
			sign_out!
		end

		it "cannot access the new action" do
			visit new_topic_post_path(@topic)
			page.current_url.should eql(sign_in_url)
		end

		it "should see the post count and last post details" do
			visit topics_path

			within "#topics tbody td#post_count" do
				page.should have_content("1")
			end

			within "#topics tbody td#last_post" do
				page.should have_content("last post was less than a minute ago by some_guy")
			end
		end

	end

	context "unauthenticated users" do
		before do
			sign_in!
		end

		it "reply to a topic" do
			visit topics_path
			click_link "First topic!"

			within ".topic #posts .post" do
				click_link "Reply!"
			end

			fill_in "Text", :with => "First reply!"
			click_button "Create Post"

			within "#flash_notice" do
				page.should have_content("Post has been created!")
			end

			within ".topic #posts .post:last" do
				page.should have_content("First reply!")
			end

			within ".topic #posts .post:last .user" do
				page.should have_content("forem_user")
			end
		end
	end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
redlumxn-forem-0.0.2 spec/integration/posts_spec.rb
redlumxn-forem-0.0.1 spec/integration/posts_spec.rb