AutoCommit Mon Aug 31 17:03:03 CEST 2015

This commit is contained in:
Andreas Stephanides
2015-08-31 17:03:03 +02:00
parent 93dbdedf53
commit 589597509a
4 changed files with 36 additions and 16 deletions

View File

@@ -9,18 +9,17 @@ class FetprofilesController < ApplicationController
@fetprofiles = Fetprofile.order(:vorname,:nachname) if params[:filter]== "all" @fetprofiles = Fetprofile.order(:vorname,:nachname) if params[:filter]== "all"
@fetprofiles = Fetprofile.where(:active=>false).order(:nachname,:vorname) if params[:filter]== "notactive" @fetprofiles = Fetprofile.where(:active=>false).order(:nachname,:vorname) if params[:filter]== "notactive"
@gremientabs = Gremium.tabs @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| respond_to do |format|
format.html # index.html.erb format.html # index.html.erb
end end
end end
def internlist def internlist
@fetprofiles = Fetprofile.order(:vorname,:nachname) @fetprofiles = Fetprofile.order(:vorname,:nachname)
end end
# GET /fetprofiles/1 # GET /fetprofiles/1
# GET /fetprofiles/1.json # GET /fetprofiles/1.json

View File

@@ -32,13 +32,13 @@ class Fetprofile < ActiveRecord::Base
has_many :nlinks, as: :link has_many :nlinks, as: :link
def validate_birthday def validate_birthday
unless birth_month.nil? || birth_day.nil? unless birth_month.nil? || birth_day.nil?
unless Date.valid_date?((birth_year.nil?) ? Date.today.year : birth_year, birth_month, birth_day) 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_month, "Invalides Datum")
errors.add(:birth_day, "Invalides Datum") errors.add(:birth_day, "Invalides Datum")
v= false v= false
else else
v= true v= true
end end
else else
v= false v= false
end end

View File

@@ -65,6 +65,10 @@ describe FetprofilesController, :type => :controller do
subject(:action) { get :show, {:id => @fetprofile.to_param}} subject(:action) { get :show, {:id => @fetprofile.to_param}}
it_behaves_like "it is success" it_behaves_like "it is success"
it_behaves_like "it assigns object" it_behaves_like "it assigns object"
it "renders the 'show' template" do
expect(action).to render_template("show")
end
end end
describe "GET new" do describe "GET new" do
@@ -104,10 +108,18 @@ describe FetprofilesController, :type => :controller do
end end
describe "POST create" do 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 login_fet_user
describe "with valid params" do 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 it "creates a new Fetprofile" do
expect{action}.to change(Fetprofile, :count).by(1) expect{action}.to change(Fetprofile, :count).by(1)
end end
@@ -115,11 +127,11 @@ describe FetprofilesController, :type => :controller do
it "assigns a newly created fetprofile as @fetprofile" do it "assigns a newly created fetprofile as @fetprofile" do
action action
expect(assigns(:fetprofile)).to be_a(Fetprofile) expect(assigns(:fetprofile)).to be_a(Fetprofile)
assigns(:fetprofile).should be_persisted expect(assigns(:fetprofile)).to be_persisted
end end
it "redirects to the created fetprofile" do it "redirects to the created fetprofile" do
expect(action).to redirect_to(Fetprofile.last) expect(action).to redirect_to action: "show"
end end
end end
@@ -129,6 +141,7 @@ describe FetprofilesController, :type => :controller do
it "assigns a newly created but unsaved fetprofile as @fetprofile" do it "assigns a newly created but unsaved fetprofile as @fetprofile" do
action action
assigns(:fetprofile).should be_a_new(Fetprofile) assigns(:fetprofile).should be_a_new(Fetprofile)
expect(assigns(:fetprofile)).not_to be_persisted
end end
it "re-renders the 'new' template" do it "re-renders the 'new' template" do
expect(action).to render_template("new") expect(action).to render_template("new")
@@ -148,6 +161,12 @@ describe FetprofilesController, :type => :controller do
it "updates the requested fetprofile" do it "updates the requested fetprofile" do
expect { action }.to change{Fetprofile.find(@fetprofile.id).vorname}#.to("neuerName") expect { action }.to change{Fetprofile.find(@fetprofile.id).vorname}#.to("neuerName")
end 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 it "redirects to the fetprofile" do
expect(action).to redirect_to(@fetprofile) expect(action).to redirect_to(@fetprofile)
end end

View File

@@ -9,5 +9,7 @@ FactoryGirl.define do
desc "MyText" desc "MyText"
picture "MyString" picture "MyString"
active false active false
birth_month 4
birth_day 2
end end
end end