diff options
| author | mo khan <mo@mokhan.ca> | 2014-08-27 20:41:25 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2014-08-27 20:41:25 -0600 |
| commit | c6324be510fea95ff6af956fc5b93e59672d0eae (patch) | |
| tree | 3f7faee2716bd2a77ecfe2fe3c11650497a6d80b /spec/controllers/tutorials_controller_spec.rb | |
| parent | 227882b0758c7918537cbdb7c49ad8fcf09d6ae5 (diff) | |
remove old tutorial actions.
Diffstat (limited to 'spec/controllers/tutorials_controller_spec.rb')
| -rw-r--r-- | spec/controllers/tutorials_controller_spec.rb | 122 |
1 files changed, 1 insertions, 121 deletions
diff --git a/spec/controllers/tutorials_controller_spec.rb b/spec/controllers/tutorials_controller_spec.rb index 9dd82c6a..1eee034c 100644 --- a/spec/controllers/tutorials_controller_spec.rb +++ b/spec/controllers/tutorials_controller_spec.rb @@ -1,15 +1,9 @@ require 'rails_helper' describe TutorialsController do - def valid_attributes - {:url => 'http://blah.com', :heading => "hello world"} - end - let(:user){ create(:user) } - before (:each) do - http_login(user) - end + before { http_login(user) } describe "#index" do let(:tutorial) { create(:tutorial) } @@ -36,118 +30,4 @@ describe TutorialsController do assigns(:tutorial).should == tutorial end end - - describe "#new" do - it "assigns a new tutorial as @tutorial" do - get :new - assigns(:tutorial).should be_a_new(Tutorial) - end - end - - describe "#edit" do - let(:tutorial) { create(:tutorial) } - - it "assigns the requested tutorial as @tutorial" do - user.tutorials << tutorial - get :edit, {:id => tutorial.to_param} - assigns(:tutorial).should eq(tutorial) - end - end - - describe "#create" do - describe "with valid params" do - before :each do - post :create, {:tutorial => {:url => 'http://blah.com', :heading => "hello world"} } - end - - it "creates a new Tutorial" do - Tutorial.count.should == 1 - end - - it "assigns a newly created tutorial as @tutorial" do - assigns(:tutorial).should be_a(Tutorial) - assigns(:tutorial).should be_persisted - assigns(:tutorial).url.should == 'http://blah.com' - assigns(:tutorial).heading.should == 'hello world' - end - - it "redirects to the created tutorial" do - response.should redirect_to(my_dashboard_path) - end - end - - describe "with invalid params" do - before :each do - Tutorial.any_instance.stub(:save).and_return(false) - post :create, {:tutorial => {:url => '', :heading => ''}} - end - - it "assigns a newly created but unsaved tutorial as @tutorial" do - assigns(:tutorial).should be_a_new(Tutorial) - end - - it "re-renders the 'new' template" do - response.should render_template("new") - end - - it "should display an error" do - flash[:error].should_not be_nil - end - end - end - - describe "#patch" do - describe "with valid params" do - let(:tutorial) { create(:tutorial) } - - before :each do - user.tutorials << tutorial - patch :update, :id => tutorial.to_param, :tutorial => { :url => 'http://blah', :heading => 'headless'} - end - - it "assigns the requested tutorial" do - assigns(:tutorial).should == tutorial - assigns(:tutorial).url.should == 'http://blah' - assigns(:tutorial).heading.should == 'headless' - end - - it "redirects to the tutorial" do - response.should redirect_to(tutorial.reload) - end - end - - describe "with invalid params" do - let(:tutorial) { create(:tutorial) } - before :each do - user.tutorials << tutorial - Tutorial.any_instance.stub(:save).and_return(false) - patch :update, {:id => tutorial.to_param, :tutorial => {:url => "", :heading => ""}} - end - - it "assigns the tutorial as @tutorial" do - assigns(:tutorial).should eq(tutorial) - end - - it "re-renders the 'edit' template" do - response.should render_template("edit") - end - end - end - - describe "#destroy" do - let(:tutorial) { create(:tutorial) } - - before :each do - user.tutorials << tutorial - delete :destroy, {:id => tutorial.to_param} - end - - it "destroys the requested tutorial" do - Tutorial.count.should == 0 - end - - it "redirects to the tutorials list" do - response.should redirect_to(my_dashboard_path) - end - end end |
