require 'spec_helper'

describe "Content creation" do 
	let(:fixxpert) { create :fixxpert }
	let(:subtrade) { create :subtrade }

	trade { page }

	before do
		login_as_user fixxpert 
		visit fixxpert_contents_path
		click_link 'Create New Content'
	end

	describe "invalid file upload" do
		before do 
			find(:xpath, "//input[@id='hidden_id']").set subtrade.id
			attach_file "file_path", '/home/charizard/loading.gif'
			click_button "submit"
		end

		it "should be able to upload", js: true do
			page.status_code.should == 200
		end
		it "should validate content_type" do
			should have_content "Document content type is invalid"
		end
	end

	describe "valid file upload" do
		before do 
			find(:xpath, "//input[@id='hidden_id']").set subtrade.id
			attach_file "file_path", '/home/charizard/Downloads/SOA-341483-072013.pdf'
			click_button "submit"
		end

		it "should be able to upload", js: true do
			page.status_code.should == 200
		end
		it "should validate content_type" do
			should have_content "Uploaded your document. Pending approval by admin."
		end
	end

end