Skip to content

Instantly share code, notes, and snippets.

UserProfile Model
xapit do |index|
index.text :first_name, :last_name
index.facet :diploma_skill
index.facet :trainings_translation_title
index.facet :first_name
index.facet :last_name
end
# Generate generic tests for instance and unsaved objects
# object as String
# uniqueness_attr as Array
# model_generic_tests("account", %w(name))
def model_generic_tests(object, uniqueness_attr=[])
context "A #{object} instance" do
setup do
@object = Factory(object.to_sym)
end
class Division < ActiveRecord::Base
has_many :agencies, :dependent => :destroy
belongs_to :country
validates_presence_of :name, :country
validates_uniqueness_of :name, :case_sensitive => false
end
mickael@mickael-laptop:~/projects/pabd$ script/console
Loading development environment (Rails 2.3.5)
>> Assignment.last
=> #<Assignment id: 5, agency_id: 1, account_id: 2, created_at: "2010-05-14 12:17:12", updated_at: "2010-05-14 12:17:12", account_type_id: 2>
>> AccountType.find(2)
=> #<AccountType id: 2, name: "Petit Compte", created_at: "2010-05-14 12:10:33", updated_at: "2010-05-14 12:10:33", deleted_at: nil>
>> AccountType.find(2).destroy
=> #<AccountType id: 2, name: "Petit Compte", created_at: "2010-05-14 12:10:33", updated_at: "2010-05-14 12:10:33", deleted_at: "2010-05-14 12:43:20">
>> AccountType.find(2)
ActiveRecord::RecordNotFound: Couldn't find AccountType with ID=2
mickael@mickael-laptop:~/projects/pabd$ rake test:units
(in /home/mickael/projects/pabd)
/usr/bin/ruby1.8 -I"lib:test" "/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/unit/user_test.rb" "test/unit/feedback_test.rb" "test/unit/country_test.rb" "test/unit/delivery_test.rb" "test/unit/function_test.rb" "test/unit/service_test.rb" "test/unit/assignment_test.rb" "test/unit/division_test.rb" "test/unit/stage_test.rb" "test/unit/helpers/divisions_helper_test.rb" "test/unit/helpers/countries_helper_test.rb" "test/unit/helpers/users_helper_test.rb" "test/unit/helpers/home_helper_test.rb" "test/unit/helpers/user_sessions_helper_test.rb" "test/unit/helpers/admin/stages_helper_test.rb" "test/unit/helpers/admin/account_helper_test.rb" "test/unit/helpers/admin/subcontract_types_helper_test.rb" "test/unit/helpers/admin/services_helper_test.rb" "test/unit/helpers/admin/admin_helper_test.rb" "test/unit/helpers/admin/skills_helper_test.rb" "test/unit/helpers/admin/functions_helper_test.rb" "test/unit/hel
France Nord-Ouest Nantes
France Nord-Ouest Centre-Bretagne Rennes
France Nord-Ouest Centre-Bretagne Tour
France Sud-Ouest Poitou-Aquitaine Niort
France Sud-Ouest Poitou-Aquitaine Bordeaux
France Sud-Ouest Toulouse
France Sud-Est Sud Marseille
France Sud-Est Sud Nice
France Sud-Est Sud Montpellier
France Sud-Est Rhône-Alpes/Auvergne Lyon
<?xml version="1.0" encoding="UTF-8"?>
<!--
Document : agencies.xml
Created on : 18 mai 2010, 16:48
Author : mickael
Description:
Purpose of the document follows.
-->
######### Recuperation du premier collaborateur
>> Collaborator.first
=> #<Collaborator id: 3, firstname: "Madisen", lastname: "Altenwerth", email: "wanda.herzog@schadenbatz.name", created_at: "2010-05-25 10:03:42", updated_at: "2010-05-25 12:27:40", function_id: 5, agency_id: 5>
######### Insertion d un évènement "changement de fonction" sur le collaborateur.
>> HrCollaboratorFunction.create!(:feedback_id => 13, :agency_id => 1, :collaborator_id => 3, :function_id => 2)
=> #<HrCollaboratorFunction id: 1, feedback_id: 13, agency_id: 1, function_id: 2, collaborator_id: 3, created_at: "2010-05-25 12:31:06", updated_at: "2010-05-25 12:31:06">
######### Affichage du premier collaborateur (il a changé de fonction)
>> Collaborator.first
We couldn’t find that file to show.
51) Error:
test: logged in on GET to :show should respond with success. (Admin::SubcontractTypesControllerTest):
ActionView::TemplateError: Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id
On line #3 of app/views/shared/_agency_time_form.html.erb
1: <% form_tag :controller => '/home', :action => 'agency_feedback' do -%>
2:
3: <%= select("home", "agency", agencies_optgroup(current_agency)) %>
4: <%= select("home", "feedback", @feedbacks.collect {|p| [ p.formated, p.id ] }, {:selected => current_time.id}) %>
5: <br />