forked from bofh/fetsite
AutoCommit Mon Aug 31 15:03:01 CEST 2015
This commit is contained in:
@@ -2,51 +2,72 @@ require 'spec_helper'
|
|||||||
|
|
||||||
describe FetprofilesController, :type => :controller do
|
describe FetprofilesController, :type => :controller do
|
||||||
let(:valid_update_attributes) { {"vorname"=>"Neuer Vorname"} }
|
let(:valid_update_attributes) { {"vorname"=>"Neuer Vorname"} }
|
||||||
# let(:valid_session) { {locale: :de} }
|
# let(:valid_session) { {locale: :de} }
|
||||||
|
shared_examples "it is success" do
|
||||||
describe "GET index" do
|
|
||||||
let(:action) { get :index, {}, valid_session}
|
|
||||||
it "has a 200 status code" do
|
it "has a 200 status code" do
|
||||||
action
|
action
|
||||||
expect(response.status).to eq(200)
|
expect(response.status).to eq(200)
|
||||||
end
|
end
|
||||||
|
it "is success" do
|
||||||
it "assigns all fetprofiles as @fetprofiles" do
|
|
||||||
fetprofile = FactoryGirl.create(:fetprofile, :active=>true)
|
|
||||||
action
|
action
|
||||||
expect(assigns(:fetprofiles)).to eq([fetprofile])
|
expect(response).to be_success
|
||||||
|
end
|
||||||
|
end
|
||||||
|
shared_examples "it assigns object" do
|
||||||
|
it "assigns object variable" do
|
||||||
|
expect(assigns(object_variable)).to eq(assigned_object_variable)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
shared_examples "it assigns new object" do
|
||||||
|
it "assigns new object" do
|
||||||
|
action
|
||||||
|
expect(assigns(object_variable)).to be_a_new(assigned_object_variable)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.create_fetprofile
|
||||||
|
before(:each) do
|
||||||
|
@fetprofile = FactoryGirl.create(:fetprofile)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
describe "GET index" do
|
||||||
|
create_fetprofile
|
||||||
|
let(:action) { get :index, {} }
|
||||||
|
before(:each) do
|
||||||
|
|
||||||
|
end
|
||||||
|
it_behaves_like "it is success"
|
||||||
|
it "assigns all fetprofiles as @fetprofiles" do
|
||||||
|
@fetprofile = FactoryGirl.create(:fetprofile)
|
||||||
|
action
|
||||||
|
expect(assigns(:fetprofiles)).to eq(Fetprofile.active)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "GET show" do
|
describe "GET show" do
|
||||||
it "assigns the requested fetprofile as @fetprofile" do
|
before(:each) do
|
||||||
fetprofile = FactoryGirl.create(:fetprofile)
|
|
||||||
get :show, {:id => fetprofile.to_param}, valid_session
|
|
||||||
assigns(:fetprofile).should eq(fetprofile)
|
|
||||||
end
|
end
|
||||||
|
subject(:action) { get :show, {:id => fetprofile.to_param}}
|
||||||
|
let(:object_variable) {:fetprofile}
|
||||||
|
let(:assigned_object_variable) {@fetprofile}
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "GET new" do
|
describe "GET new" do
|
||||||
describe "with fetuser" do
|
describe "with fetuser" do
|
||||||
login_fet_user
|
login_fet_user
|
||||||
it "is success" do
|
subject(:action) { get :new, {}}
|
||||||
get :new, {}
|
let(:object_variable) {:fetprofile}
|
||||||
expect(response).to be_success
|
let(:assigned_object_variable) {Fetprofile}
|
||||||
end
|
|
||||||
it "assigns @fetprofile" do
|
it_behaves_like "it assigns new object"
|
||||||
get :new, {}
|
it_behaves_like "it is success"
|
||||||
expect(assigns(:fetprofile)).to be_a_new(Fetprofile)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
describe "without fetuser" do
|
describe "without fetuser" do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
sign_out :user
|
sign_out :user
|
||||||
end
|
end
|
||||||
it "doesn't assign @fetprofile" do
|
pending "doesn't assign @fetprofile"
|
||||||
|
|
||||||
get :new, {}
|
|
||||||
expect(assigns(:fetprofile)).to be_nil #_a_new(Fetprofile)
|
|
||||||
end
|
|
||||||
it "is expected to raise error" do
|
it "is expected to raise error" do
|
||||||
bypass_rescue
|
bypass_rescue
|
||||||
expect { get :new }.to raise_error(CanCan::AccessDenied)
|
expect { get :new }.to raise_error(CanCan::AccessDenied)
|
||||||
@@ -59,11 +80,16 @@ describe FetprofilesController, :type => :controller do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe "GET edit" do
|
describe "GET edit" do
|
||||||
it "assigns the requested fetprofile as @fetprofile" do
|
login_fet_user
|
||||||
fetprofile = FactoryGirl.create(:fetprofile)
|
before(:each) do
|
||||||
get :edit, {:id => fetprofile.to_param}, valid_session
|
@fetprofile = FactoryGirl.create(:fetprofile)
|
||||||
assigns(:fetprofile).should eq(fetprofile)
|
|
||||||
end
|
end
|
||||||
|
subject(:action) {get :edit, :id=>@fetprofile.to_param}
|
||||||
|
it "assigns the requested fetprofile as @fetprofile" do
|
||||||
|
expect{action}.to change {assigns(:fetprofile)}.to(@fetprofile)
|
||||||
|
# expect(assigns(:fetprofile)).to eq(@fetprofile)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "POST create" do
|
describe "POST create" do
|
||||||
|
|||||||
Reference in New Issue
Block a user