AutoCommit Die Sep 1 12:03:25 CEST 2015

This commit is contained in:
Andreas Stephanides
2015-09-01 12:03:25 +02:00
parent c1a7d9b7c2
commit c37040a74b

View File

@@ -20,15 +20,36 @@ describe "fetprofiles/show", :type => :view do
user.add_role(:fetuser)
# user.confirm!
@user=user
@ability=Ability.new(@user)
@ability= Ability.new(@user)
# controller.stub(:current_ability) { @ability }
allow(view).to receive(:current_ability).and_return(@ability)
sign_in user
end
end
it "calls vorname on fetprofile" do
expect(@fetprofile).to receive(:vorname).at_least(1).times
render
end
it "doesn't call users" do
Fetprofile.any_instance.should_not_receive(:users)
# expect(Fetprofile.any_instance).to receive(:vorname)
render
end
it "doesn't call memberships" do
Fetprofile.any_instance.should_not_receive(:memberships)
render
end
it "doesn't call gremien" do
Fetprofile.any_instance.should_not_receive(:gremien)
render
end
it "renders public attributes" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
# puts rendered
expect(rendered).to match(/#{@fetprofile.vorname}/)
expect(rendered).to match(/#{@fetprofile.nachname}/)
expect(rendered).to match(/#{@fetprofile.desc}/)
@@ -50,21 +71,17 @@ describe "fetprofiles/show", :type => :view do
describe "with fet user" do
login_fet_user
it "can see intern" do
@ability = Object.new
@ability.extend(CanCan::Ability)
controller.stub(:current_ability) { @ability }
allow(view).to receive(:current_ability).and_return(@ability)
# view.stub!(:current_ability).and_return(@ability)
expect(current_ability.can?(:seeintern,@fetprofile)).to be true
expect(@ability.can?(:seeintern,@fetprofile)).to be true
end
let(:current_ability) {@ability}
it "renders secrets" do
@ability.can(:seeintern,@fetprofile)
allow(view).to receive(:current_ability).and_return(@ability)
expect(rendered).to match(/#{@fetprofile.street}/)
render
expect(rendered).to match(/#{@fetprofile.street}/)
end
it "renders edit path" do
render
expect(rendered).to match(/#{edit_fetprofile_path(@fetprofile)}/)
end
end
end