AutoCommit Son Aug 30 18:03:01 CEST 2015
This commit is contained in:
@@ -16,7 +16,13 @@
|
|||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
I18n.locale = session[:locale] || request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^de|en/).first || I18n.default_locale
|
http_header=request.env['HTTP_ACCEPT_LANGUAGE']
|
||||||
|
unless http_header.nil?
|
||||||
|
ht= http_header.scan(/^de|en/).first
|
||||||
|
else
|
||||||
|
ht=nil
|
||||||
|
end
|
||||||
|
I18n.locale = session[:locale] || ht || I18n.default_locale
|
||||||
|
|
||||||
|
|
||||||
session[:locale] = I18n.locale
|
session[:locale] = I18n.locale
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ describe FetprofilesController, :type=> :controller do
|
|||||||
# This should return the minimal set of attributes required to create a valid
|
# This should return the minimal set of attributes required to create a valid
|
||||||
# Fetprofile. As you add validations to Fetprofile, be sure to
|
# Fetprofile. As you add validations to Fetprofile, be sure to
|
||||||
# adjust the attributes here as well.
|
# adjust the attributes here as well.
|
||||||
let(:valid_attributes) { {} }
|
let(:valid_attributes) { {"vorname"=>"Neuer Vorname"} }
|
||||||
|
|
||||||
# This should return the minimal set of values that should be in the session
|
# This should return the minimal set of values that should be in the session
|
||||||
# in order to pass any filters (e.g. authentication) defined in
|
# in order to pass any filters (e.g. authentication) defined in
|
||||||
@@ -70,18 +70,19 @@ describe FetprofilesController, :type=> :controller do
|
|||||||
describe "with valid params" do
|
describe "with valid params" do
|
||||||
it "creates a new Fetprofile" do
|
it "creates a new Fetprofile" do
|
||||||
expect {
|
expect {
|
||||||
post :create, {:fetprofile => FactoryGirl.create(:fetprofile).to_hash}, valid_session
|
post :create, {:fetprofile => FactoryGirl.create(:fetprofile).attributes}, valid_session
|
||||||
}.to change(Fetprofile, :count).by(1)
|
}.to change(Fetprofile, :count).by(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
it "assigns a newly created fetprofile as @fetprofile" do
|
it "assigns a newly created fetprofile as @fetprofile" do
|
||||||
post :create, {:fetprofile => FactoryGirl.create(:fetprofile).to_hash}, valid_session
|
post :create, {:fetprofile => FactoryGirl.create(:fetprofile).attributes}, valid_session
|
||||||
assigns(:fetprofile).should be_a(Fetprofile)
|
assigns(:fetprofile).should be_a(Fetprofile)
|
||||||
assigns(:fetprofile).should be_persisted
|
assigns(:fetprofile).should be_persisted
|
||||||
end
|
end
|
||||||
|
|
||||||
it "redirects to the created fetprofile" do
|
it "redirects to the created fetprofile" do
|
||||||
post :create, {:fetprofile => FactoryGirl.create(:fetprofile).to_hash}, valid_session
|
post :create, {:fetprofile => FactoryGirl.create(:fetprofile).attributes}, valid_session
|
||||||
response.should redirect_to(Fetprofile.last)
|
response.should redirect_to(Fetprofile.last)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -104,26 +105,31 @@ describe FetprofilesController, :type=> :controller do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe "PUT update" do
|
describe "PUT update" do
|
||||||
|
before(:each) do
|
||||||
|
u= FactoryGirl.create(:user)
|
||||||
|
u.add_role(:fetuser)
|
||||||
|
sign_in u
|
||||||
|
end
|
||||||
describe "with valid params" do
|
describe "with valid params" do
|
||||||
it "updates the requested fetprofile" do
|
it "updates the requested fetprofile" do
|
||||||
fetprofile = FactoryGirl.create(:fetprofile)
|
fetprofile = FactoryGirl.create(:fetprofile)
|
||||||
# Assuming there are no other fetprofiles in the database, this
|
|
||||||
# specifies that the Fetprofile created on the previous line
|
# Fetprofile.any_instance.should_receive(:update_attributes).with({"vorname"=>"neuerName"})
|
||||||
# receives the :update_attributes message with whatever params are
|
expect {
|
||||||
# submitted in the request.
|
put :update, {:id => fetprofile.to_param, :fetprofile => {"vorname"=>"neuerName"}}, valid_session
|
||||||
Fetprofile.any_instance.should_receive(:update_attributes).with({ "vorname" => "MyString" })
|
puts Fetprofile.find(fetprofile.id).vorname
|
||||||
put :update, {:id => fetprofile.to_param, :fetprofile => { "vorname" => "MyString" }}, valid_session
|
}.to change{Fetprofile.find(fetprofile.id).vorname}#.to("neuerName")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "assigns the requested fetprofile as @fetprofile" do
|
it "assigns the requested fetprofile as @fetprofile" do
|
||||||
fetprofile = FactoryGirl.create(:fetprofile)
|
fetprofile = FactoryGirl.create(:fetprofile)
|
||||||
put :update, {:id => fetprofile.to_param, :fetprofile => valid_attributes}, valid_session
|
put :update, {:id => fetprofile.to_param, :fetprofile=> {}}#, valid_session
|
||||||
assigns(:fetprofile).should eq(fetprofile)
|
expect(assigns(:fetprofile)).to eq(fetprofile)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "redirects to the fetprofile" do
|
it "redirects to the fetprofile" do
|
||||||
fetprofile = FactoryGirl.create(:fetprofile)
|
fetprofile = FactoryGirl.create(:fetprofile)
|
||||||
put :update, {:id => fetprofile.to_param, :fetprofile => valid_attributes}, valid_session
|
put :update, {:id => fetprofile.to_param, :fetprofile => {"vorname"=>"neuerName"}}#, valid_session
|
||||||
response.should redirect_to(fetprofile)
|
response.should redirect_to(fetprofile)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -133,15 +139,17 @@ describe FetprofilesController, :type=> :controller do
|
|||||||
fetprofile = FactoryGirl.create(:fetprofile)
|
fetprofile = FactoryGirl.create(:fetprofile)
|
||||||
# Trigger the behavior that occurs when invalid params are submitted
|
# Trigger the behavior that occurs when invalid params are submitted
|
||||||
Fetprofile.any_instance.stub(:save).and_return(false)
|
Fetprofile.any_instance.stub(:save).and_return(false)
|
||||||
put :update, {:id => fetprofile.to_param, :fetprofile => { "vorname" => "invalid value" }}, valid_session
|
put :update, {:id => fetprofile.to_param, :fetprofile => { "vorname" => "invalid value" }}#, valid_session
|
||||||
assigns(:fetprofile).should eq(fetprofile)
|
expect(assigns(:fetprofile)).to eq(fetprofile)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "re-renders the 'edit' template" do
|
it "re-renders the 'edit' template" do
|
||||||
fetprofile = FactoryGirl.create(:fetprofile)
|
fetprofile = FactoryGirl.create(:fetprofile)
|
||||||
|
attributes= Fetprofile.attributes
|
||||||
# Trigger the behavior that occurs when invalid params are submitted
|
# Trigger the behavior that occurs when invalid params are submitted
|
||||||
Fetprofile.any_instance.stub(:save).and_return(false)
|
Fetprofile.any_instance.stub(:save).and_return(false)
|
||||||
put :update, {:id => fetprofile.to_param, :fetprofile => { "vorname" => "invalid value" }}, valid_session
|
put :update, {:id => fetprofile.to_param, :fetprofile => attributes}, valid_session
|
||||||
response.should render_template("edit")
|
response.should render_template("edit")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
8
spec/factories/users.rb
Normal file
8
spec/factories/users.rb
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
FactoryGirl.define do
|
||||||
|
factory :user do
|
||||||
|
email "testuser@test.at"
|
||||||
|
password "password"
|
||||||
|
password_confirmation "password"
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,7 +1,4 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe User do
|
describe User do
|
||||||
email "testuser@test.at"
|
|
||||||
password "password"
|
|
||||||
password_confirmation "password"
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user