AutoCommit Don Sep 3 16:03:01 CEST 2015

This commit is contained in:
Andreas Stephanides
2015-09-03 16:03:01 +02:00
parent 984e5f4b56
commit f7ad93c398
6 changed files with 164 additions and 142 deletions

View File

@@ -16,6 +16,7 @@ RSpec.configure do |config|
config.extend ControllerMacros, :type => :controller config.extend ControllerMacros, :type => :controller
config.include Devise::TestHelpers, :type => :view config.include Devise::TestHelpers, :type => :view
config.include RSpecHtmlMatchers, :type => :view config.include RSpecHtmlMatchers, :type => :view
config.extend ViewMacros, :type => :view
end end
@@ -42,7 +43,8 @@ RSpec.configure do |config|
# automatically. This will be the default behavior in future versions of # automatically. This will be the default behavior in future versions of
# rspec-rails. # rspec-rails.
config.infer_base_class_for_anonymous_controllers = false config.infer_base_class_for_anonymous_controllers = false
config.add_setting :themes
config.themes =[:blue2, :blue1]
# Run specs in random order to surface order dependencies. If you find an # Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing # order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run. # the seed, which is printed after each run.

View File

@@ -0,0 +1,30 @@
module ViewMacros
def foreach_theme
RSpec.configuration.themes.each do |theme|
context " with theme #{theme}" do
before(:each) do
view.view_paths=[ "app/views/themes/#{theme}", "app/views"]
end
yield
end
end
end
def 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)
# controller.stub(:current_ability) { @ability }
allow(view).to receive(:current_ability).and_return(@ability)
sign_in user
end
end
end

View File

@@ -1,30 +1,35 @@
require 'spec_helper' require 'spec_helper'
describe "fetprofiles/edit" do describe "fetprofiles/edit", :type=> :view do
foreach_theme do
login_fet_user
before(:each) do before(:each) do
@fetprofile = assign(:fetprofile, stub_model(Fetprofile, @fetprofile = FactoryGirl.create(:fetprofile_withadress,:skype => "myskypename")
:vorname => "MyString", @memberships = []
:nachname => "MyString",
:short => "MyString",
:fetmailalias => "MyString",
:desc => "MyText",
:picture => "MyString",
:active => false
))
end end
it "renders the edit fetprofile form" do it "renders the edit fetprofile form" do
render render
# Run the generator again with the --webrat flag if you want to use webrat matchers # Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "form[action=?][method=?]", fetprofile_path(@fetprofile), "post" do expect(rendered).to have_tag('form', with: {method:"post"}) do
assert_select "input#fetprofile_vorname[name=?]", "fetprofile[vorname]" with_tag "input", with: {name: "fetprofile[vorname]", value: @fetprofile.vorname}
assert_select "input#fetprofile_nachname[name=?]", "fetprofile[nachname]" with_tag "input", with: {name: "fetprofile[nachname]", value: @fetprofile.nachname}
assert_select "input#fetprofile_short[name=?]", "fetprofile[short]" with_tag "input", with: {name: "fetprofile[short]", value: @fetprofile.short}
assert_select "input#fetprofile_fetmailalias[name=?]", "fetprofile[fetmailalias]" with_tag "textarea", with: {name: "fetprofile[desc]"}
assert_select "textarea#fetprofile_desc[name=?]", "fetprofile[desc]" with_tag "input", with: {name: "fetprofile[picture]"}
assert_select "input#fetprofile_picture[name=?]", "fetprofile[picture]" with_tag "input", with: {name: "fetprofile[picture_cache]"}
assert_select "input#fetprofile_active[name=?]", "fetprofile[active]"
with_tag "input", with: {name: "fetprofile[street]", value: @fetprofile.street}
with_tag "input", with: {name: "fetprofile[plz]", value: @fetprofile.plz}
with_tag "input", with: {name: "fetprofile[city]", value: @fetprofile.city}
with_tag "input", with: {name: "fetprofile[hdynr]", value: @fetprofile.hdynr}
with_tag "input", with: {name: "fetprofile[telnr]", value: @fetprofile.telnr}
with_tag "input", with: {name: "fetprofile[skype]", value: @fetprofile.skype.to_s}
with_tag "input", with: {name: "fetprofile[birth_day]", value: @fetprofile.birth_day}
with_tag "input", with: {name: "fetprofile[birth_month]", value: @fetprofile.birth_month}
end
end end
end end
end end

View File

@@ -2,7 +2,7 @@ require 'spec_helper'
describe "fetprofiles/index" , :type=>:view do describe "fetprofiles/index" , :type=>:view do
foreach_theme do
before(:each) do before(:each) do
# default_url_options[:locale] = :de # default_url_options[:locale] = :de
@fetprofile1 = FactoryGirl.create(:fetprofile) @fetprofile1 = FactoryGirl.create(:fetprofile)
@@ -29,3 +29,4 @@ describe "fetprofiles/index" , :type=>:view do
end end
end end
end

View File

@@ -1,30 +1,35 @@
require 'spec_helper' require 'spec_helper'
describe "fetprofiles/new" do describe "fetprofiles/new", :type=> :view do
foreach_theme do
before(:each) do before(:each) do
assign(:fetprofile, stub_model(Fetprofile, @fetprofile = FactoryGirl.create(:fetprofile_withadress,:skype => "myskypename")
:vorname => "MyString", @memberships = []
:nachname => "MyString",
:short => "MyString",
:fetmailalias => "MyString",
:desc => "MyText",
:picture => "MyString",
:active => false
).as_new_record)
end end
it "renders new fetprofile form" do it "renders the edit fetprofile form" do
render render
# Run the generator again with the --webrat flag if you want to use webrat matchers # Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "form[action=?][method=?]", fetprofiles_path, "post" do expect(rendered).to have_tag('form', with: {method:"post"}) do
assert_select "input#fetprofile_vorname[name=?]", "fetprofile[vorname]" with_tag "input", with: {name: "fetprofile[vorname]"}
assert_select "input#fetprofile_nachname[name=?]", "fetprofile[nachname]" with_tag "input", with: {name: "fetprofile[nachname]"}
assert_select "input#fetprofile_short[name=?]", "fetprofile[short]" with_tag "input", with: {name: "fetprofile[short]"}
assert_select "input#fetprofile_fetmailalias[name=?]", "fetprofile[fetmailalias]" with_tag "textarea", with: {name: "fetprofile[desc]"}
assert_select "textarea#fetprofile_desc[name=?]", "fetprofile[desc]" with_tag "input", with: {name: "fetprofile[picture]"}
assert_select "input#fetprofile_picture[name=?]", "fetprofile[picture]" with_tag "input", with: {name: "fetprofile[picture_cache]"}
assert_select "input#fetprofile_active[name=?]", "fetprofile[active]"
with_tag "input", with: {name: "fetprofile[street]"}
with_tag "input", with: {name: "fetprofile[plz]"}
with_tag "input", with: {name: "fetprofile[city]"}
with_tag "input", with: {name: "fetprofile[hdynr]"}
with_tag "input", with: {name: "fetprofile[telnr]"}
with_tag "input", with: {name: "fetprofile[skype]"}
with_tag "input", with: {name: "fetprofile[birth_day]"}
with_tag "input", with: {name: "fetprofile[birth_month]"}
end end
end end
end end
end

View File

@@ -1,14 +1,8 @@
require 'spec_helper' require 'spec_helper'
#ActionView.lookup_context.prefixes = ['app/views/themes/blue2']
# ActionView.any_instance.stub!(:view_paths).and_return([ 'app/views/themes/blue2'])
describe "fetprofiles/show", :type => :view do describe "fetprofiles/show", :type => :view do
["blue2"].each do |theme| foreach_theme do
describe "theme #{theme}" do
before(:each) do
view.view_paths=[ "app/views/themes/#{theme}", "app/views"]
end
before(:each) do before(:each) do
default_url_options[:locale] = :de default_url_options[:locale] = :de
@fetprofile = FactoryGirl.create(:fetprofile_withadress) @fetprofile = FactoryGirl.create(:fetprofile_withadress)
@@ -21,21 +15,7 @@ describe "fetprofiles/show", :type => :view do
assign(:gremientabs, [@gremium2]) assign(:gremientabs, [@gremium2])
# view.theme "blue2" # view.theme "blue2"
end 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)
# controller.stub(:current_ability) { @ability }
allow(view).to receive(:current_ability).and_return(@ability)
sign_in user
end
end
it "has working filters" do it "has working filters" do
expect(true).to be true expect(true).to be true
end end
@@ -119,4 +99,3 @@ end
end end
end end
end end
end