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