AutoCommit Die Sep 1 10:03:01 CEST 2015
This commit is contained in:
@@ -14,6 +14,9 @@ Dir[Rails.root.join("spec/controllers/shared_examples/**/*.rb")].each {|f| requi
|
||||
RSpec.configure do |config|
|
||||
config.include Devise::TestHelpers, :type => :controller
|
||||
config.extend ControllerMacros, :type => :controller
|
||||
config.include Devise::TestHelpers, :type => :view
|
||||
config.include RSpecHtmlMatchers, :type => :view
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "fetprofiles/show", :type => :view do
|
||||
describe "fetprofiles/_fetprofile", :type => :view do
|
||||
include RSpecHtmlMatchers
|
||||
before(:each) do
|
||||
include Devise::TestHelpers
|
||||
include Rails.application.routes.url_helpers
|
||||
before(:each) do
|
||||
# @fetprofile =
|
||||
#assign(:fetprofile, stub_model(Fetprofile, FactoryGirl.attributes_for(:fetprofile)))
|
||||
default_url_options[:locale] = :de
|
||||
@@ -10,8 +12,20 @@ describe "fetprofiles/show", :type => :view do
|
||||
# assign(:fetprofile,@fetprofile)
|
||||
# assign(:memberships, [])
|
||||
end
|
||||
|
||||
it "has access to url_helpers" do
|
||||
expect(fetprofile_path(@fetprofile,locale: "de",theme: nil)).to match /#{@fetprofile.id}/
|
||||
end
|
||||
|
||||
it "has access to url_helpers without setting nil params" do
|
||||
expect(fetprofile_path(@fetprofile)).to match /#{@fetprofile.id}/
|
||||
end
|
||||
it "renders a link" do
|
||||
render partial: "fetprofiles/fetprofile"
|
||||
allow(view).to receive(:default_url_options).and_return({locale: "de"})
|
||||
# allow(view).to receive(:fetprofile_path).and_return("")
|
||||
|
||||
# view.stub!(:fetprofile_path).and_return("path")
|
||||
render partial: "fetprofiles/fetprofile", locals: {fetprofile: @fetprofile}
|
||||
expect(rendered).to have_tag("a.linkbox")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,22 +1,41 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "fetprofiles/show", :type => :view do
|
||||
include RSpecHtmlMatchers
|
||||
# include RSpecHtmlMatchers
|
||||
before(:each) do
|
||||
# @fetprofile =
|
||||
#assign(:fetprofile, stub_model(Fetprofile, FactoryGirl.attributes_for(:fetprofile)))
|
||||
default_url_options[:locale] = :de
|
||||
@fetprofile = FactoryGirl.create(:fetprofile)
|
||||
@fetprofile = FactoryGirl.create(:fetprofile,:street => "secret adress")
|
||||
assign(:fetprofile,@fetprofile)
|
||||
assign(:memberships, [])
|
||||
assign(:gremientabs, [])
|
||||
end
|
||||
def self.login_fet_user
|
||||
before(:each) do
|
||||
@request.env["devise.mapping"] = Devise.mappings[:user]
|
||||
user = FactoryGirl.build(:user)
|
||||
user = User.find_by_email(user.email) || user
|
||||
user.save
|
||||
user.add_role(:fetuser)
|
||||
# user.confirm!
|
||||
@user=user
|
||||
@ability=Ability.new(@user)
|
||||
sign_in user
|
||||
end
|
||||
end
|
||||
|
||||
it "renders attributes in <p>" do
|
||||
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 include_text @fetprofile.vorname
|
||||
# puts rendered
|
||||
expect(rendered).to match(/#{@fetprofile.vorname}/)
|
||||
expect(rendered).to match(/#{@fetprofile.nachname}/)
|
||||
expect(rendered).to match(/#{@fetprofile.desc}/)
|
||||
expect(rendered).to match(/#{@fetprofile.fetmail}/)
|
||||
|
||||
expect(rendered).to have_tag('div')
|
||||
|
||||
# rendered.should match(/Nachname/)
|
||||
# rendered.should match(/Short/)
|
||||
# rendered.should match(/Fetmailalias/)
|
||||
@@ -24,4 +43,28 @@ describe "fetprofiles/show", :type => :view do
|
||||
|
||||
# rendered.should match(/false/)
|
||||
end
|
||||
it "doesn't render secrets" do
|
||||
render
|
||||
expect(rendered).not_to match(/#{@fetprofile.street}/)
|
||||
end
|
||||
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
|
||||
end
|
||||
it "renders secrets" do
|
||||
@ability.can(:seeintern,@fetprofile)
|
||||
allow(view).to receive(:current_ability).and_return(@ability)
|
||||
|
||||
expect(rendered).to match(/#{@fetprofile.street}/)
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user