I would like to write a test to make sure that "expert" users can create articles, and "basic" users cannot. For example, basic user cannot go here: "http://0.0.0.0:3000/articles/new"
. Below is a shortened version of my articles controller, followed by the articles test. The controller works, but I would like the test to prove it out. I'm not sure what to put where it says "code goes here". Thanks.
articles_controller:
class ArticlesController < ApplicationController
load_and_authorize_resource
# GET /articles/new
# GET /articles/new.json
def new
puts "in articles new"
@article = Article.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @article }
end
end
end
articles_controller_spec:
describe ArticlesController do
before (:each) do
@user = FactoryGirl.create(:user)
@user.role = "basic"
sign_in @user
end
describe "create article" do
it "should not create new article" do
#code goes here
end
end
end