AutoCommit Mon Aug 31 17:03:03 CEST 2015
This commit is contained in:
@@ -9,18 +9,17 @@ class FetprofilesController < ApplicationController
|
||||
@fetprofiles = Fetprofile.order(:vorname,:nachname) if params[:filter]== "all"
|
||||
@fetprofiles = Fetprofile.where(:active=>false).order(:nachname,:vorname) if params[:filter]== "notactive"
|
||||
|
||||
|
||||
@gremientabs = Gremium.tabs
|
||||
@toolbar_elements << {:hicon=>'icon-plus', :text=> I18n.t('profile.new_profile'),:path => new_fetprofile_path(@fetprofile) } if can? :new, @fetprofile
|
||||
@toolbar_elements << {:hicon=>'icon-plus', :text=> I18n.t('profile.new_profile'),:path => new_fetprofile_path(@fetprofile) } if can? :new, @fetprofile
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def internlist
|
||||
@fetprofiles = Fetprofile.order(:vorname,:nachname)
|
||||
end
|
||||
end
|
||||
|
||||
# GET /fetprofiles/1
|
||||
# GET /fetprofiles/1.json
|
||||
|
||||
@@ -32,13 +32,13 @@ class Fetprofile < ActiveRecord::Base
|
||||
has_many :nlinks, as: :link
|
||||
def validate_birthday
|
||||
unless birth_month.nil? || birth_day.nil?
|
||||
unless Date.valid_date?((birth_year.nil?) ? Date.today.year : birth_year, birth_month, birth_day)
|
||||
errors.add(:birth_month, "Invalides Datum")
|
||||
errors.add(:birth_day, "Invalides Datum")
|
||||
v= false
|
||||
else
|
||||
v= true
|
||||
end
|
||||
unless Date.valid_date?((birth_year.nil?) ? Date.today.year : birth_year, birth_month, birth_day)
|
||||
errors.add(:birth_month, "Invalides Datum")
|
||||
errors.add(:birth_day, "Invalides Datum")
|
||||
v= false
|
||||
else
|
||||
v= true
|
||||
end
|
||||
else
|
||||
v= false
|
||||
end
|
||||
|
||||
@@ -65,6 +65,10 @@ describe FetprofilesController, :type => :controller do
|
||||
subject(:action) { get :show, {:id => @fetprofile.to_param}}
|
||||
it_behaves_like "it is success"
|
||||
it_behaves_like "it assigns object"
|
||||
it "renders the 'show' template" do
|
||||
expect(action).to render_template("show")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "GET new" do
|
||||
@@ -104,22 +108,30 @@ describe FetprofilesController, :type => :controller do
|
||||
end
|
||||
|
||||
describe "POST create" do
|
||||
subject(:action){post :create, {:fetprofile => FactoryGirl.build(:fetprofile).attributes.slice(:vorname, :nachname,:desc)}}
|
||||
subject(:action){post :create, {:fetprofile => FactoryGirl.attributes_for(:fetprofile)},:format=>:html}
|
||||
|
||||
login_fet_user
|
||||
describe "with valid params" do
|
||||
# login_fet_user
|
||||
it "uses valid params" do
|
||||
expect(Fetprofile.new({:vorname => "sdfsdf", :nachname=>"sdfefw",:desc=>"sdfsdfe"}).save).to be true
|
||||
end
|
||||
# before(:each) do
|
||||
# Fetprofile.any_instance.stub(:save).and_return(true)
|
||||
# end
|
||||
|
||||
it "creates a new Fetprofile" do
|
||||
expect{action}.to change(Fetprofile, :count).by(1)
|
||||
end
|
||||
|
||||
|
||||
it "assigns a newly created fetprofile as @fetprofile" do
|
||||
action
|
||||
expect(assigns(:fetprofile)).to be_a(Fetprofile)
|
||||
assigns(:fetprofile).should be_persisted
|
||||
expect(assigns(:fetprofile)).to be_persisted
|
||||
end
|
||||
|
||||
|
||||
it "redirects to the created fetprofile" do
|
||||
expect(action).to redirect_to(Fetprofile.last)
|
||||
expect(action).to redirect_to action: "show"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -129,6 +141,7 @@ describe FetprofilesController, :type => :controller do
|
||||
it "assigns a newly created but unsaved fetprofile as @fetprofile" do
|
||||
action
|
||||
assigns(:fetprofile).should be_a_new(Fetprofile)
|
||||
expect(assigns(:fetprofile)).not_to be_persisted
|
||||
end
|
||||
it "re-renders the 'new' template" do
|
||||
expect(action).to render_template("new")
|
||||
@@ -148,6 +161,12 @@ describe FetprofilesController, :type => :controller do
|
||||
it "updates the requested fetprofile" do
|
||||
expect { action }.to change{Fetprofile.find(@fetprofile.id).vorname}#.to("neuerName")
|
||||
end
|
||||
it "assigns a created fetprofile as @fetprofile" do
|
||||
action
|
||||
expect(assigns(:fetprofile)).to be_a(Fetprofile)
|
||||
expect(assigns(:fetprofile)).to be_persisted
|
||||
end
|
||||
|
||||
it "redirects to the fetprofile" do
|
||||
expect(action).to redirect_to(@fetprofile)
|
||||
end
|
||||
|
||||
@@ -9,5 +9,7 @@ FactoryGirl.define do
|
||||
desc "MyText"
|
||||
picture "MyString"
|
||||
active false
|
||||
birth_month 4
|
||||
birth_day 2
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user