Displaying 20 results from an estimated 600 matches similar to: "Mock or Stub strategy for validates_uniqueness_of"
2007 Mar 26
2
Failure creating model in spec setup not reported?
Hi
I''ve just tracked down a wierd error that AFAICT is caused by an
error not being raised in the setup:
context "An Asset" do
setup do
@provider = Provider.create(:name => "Provider1")
@product = Product.new(:name => "Product1", :provider =>
@provider)
@applicant = Applicant.new(:first_name =>
2007 Jul 24
4
Possible Bug
I''m trying to test some code that has validates each and I''ve got a very
strange failure
Mock ''Book_1027'' expected :store_with_privacy? with (#<Clip:0x1a99b96
@name="Clip_1025">) but received it with (#<Clip:0x1a99b96
@name="Clip_1025">)
The Spec
it "should check that a book can save a clip" do
@user =
2010 Oct 06
2
reflect_on_association method
Hi all, I am having trouble trying to use reflect_on_association
method with given the simplified model:
class Order < ActiveRecord::Base
belongs_to :contractor, :class_name => "BusinessUnit"
end
I expected the reflect_on_association method to return
associated_foreign_key "contractor_id" but it returns
"business_unit_id":
ruby-1.9.2-p0 >
2012 Dec 14
11
Puppet and Mcollective yaml file changing when it shouldn't
Has anyone else ran into this?
debug: /Stage[main]/Mcollective/File[/var/tmp/facts.yaml]/content:
Executing ''diff -u /var/tmp/facts.yaml
/tmp/puppet-file20121214-13448-933j3r-0''
notice: /Stage[main]/Mcollective/File[/var/tmp/facts.yaml]/content:
--- /var/tmp/facts.yaml 2012-12-14 00:53:20.000000000 +0000
+++ /tmp/puppet-file20121214-13448-933j3r-0 2012-12-14
2011 Nov 04
2
problem with templates
I am having an issue with templates that I cant quite figure out why
it is having an issue.
I am using ruby dsl to read a template from a database and it keeps
having problems with anything other than <%= var %> type definitions.
I even went as far cutting and pasting from the puppet online
documentation just to see if it were maybe something I goofed. I
pasted below the tested template
2006 Jul 06
4
Need advice on code-like columns
Hello!
I''m trying to move to rails from traditional web app.
As Rails has some conventions about table schema,
I met some obstacles.
Questions.
1.
This is a sort of general question. Do you make a code table for things
like the following?
Activity Status Codes
01001: Open
01002: Pending
01003: Delayed
01004: Cancelled
01005: Closed
(The first 2 digits are code category.)
Would you
2007 Aug 10
1
How to spec a model method
Still new to Specs...
How do I create a spec to test a model method? Specifically, here is my
spec:
#testing model
describe User do
it "should have many user roles" do
User.reflect_on_association(:user_roles).should_not be_nil
end
it "should have many roles though user roles" do
User.reflect_on_association(:roles).should_not be_nil
end
it "should know
2006 May 14
4
searching on foreing keys
Hey all,
I''m using a simple search function. It''s working
great except for foreign keys.
I have one table pets (id,name,owner_id)
and another table people(id,name)
owner_id being a foreign key of pet pointing to people name.
here it is on the pet controller:
@paginator, @pets= paginate(:pets, :conditions =>["name OR owner_id
like
2012 Dec 03
4
Unnecessary changes when creating facts.yaml
I have set up puppet to create a facts.yaml file for mcollective using the
following line:
content => inline_template("<%= scope.to_hash.reject { |k,v| k.to_s =~
/(uptime.*|timestamp|.*free|macaddress.*|ipaddress)/ }.to_yaml %>"),
However, it is creating a lot of unnecessary changes by reordering the
facts in the yaml output as you can see in the diff output between to
2007 Mar 18
7
How to get more informations about an association at runtime
Hi all
I''m working on a Custom Formbuilder. I want it to create me with a
single method call checkboxes for a given HABTM association.
My model looks like this:
[code=ruby]class Member < ActiveRecord::Base
has_and_belongs_to_many :preferred_music_styles,
:class_name => ''MusicStyle'',
:join_table =>
2012 Jul 05
1
hash to_yaml in erb template not giving valid yaml
Hi,
I want to use a file resource to write a facts.yaml file for
Mcollective. For some reason it won''t provide a valid yaml format if I
dump my scope to hash and convert to_yaml.
file {
"/etc/mcollective/facts.yaml" :
owner => root,
group => root,
mode => 400,
loglevel => debug,
#content => inline_template("<%= scope.to_hash.reject {
2008 Jan 08
1
odd facter error with split
Not sure if this is another issue cropping up with 0.24.1 but I''m getting
the following:
info: Loading fact raid
/etc/puppet/facts/location.rb:5: private method `split'' called for
nil:NilClass (NoMethodError)
from /usr/lib/ruby/site_ruby/1.8/facter.rb:510:in `call''
from /usr/lib/ruby/site_ruby/1.8/facter.rb:510:in `value''
from
2006 Apr 19
2
Using Reflections to find out ActiveRecord class association
I want to find out what are the associations with another active record
class. So If my class is as below:
Class Component < ActiveRecord::Base
has_many :branches
end
class Branch < ActiveRecord::Base
belongs_to :component
end
and then I do
Component.reflections[:branches].active_record
I would expect that to be Branch but it is in fact Component.
The inspection of
2007 May 23
10
Modifying Conditions for has_many at runtime in controller?
I am attempting to bring Rails into my company, and so far I have been
able to impress the senior managers with the flexibility /
configurability of Rails on ActiveScaffold. I have hit a point now
where I am stumped, and would really appreciate the help of the
community.
I have a Person ActiveRecord model that has_many Orders.
class Person < ActiveRecord::Base
has_many :orders
end
I am
2007 Dec 10
10
Reading Hash/Array
Hi all,
My app is generating a form with several bill_items that should be
updated (fields to be updated are description and net).
The text_field_tag names are bill_item[update][#{id}][description] and
bill_item[update][#{id}][net] (and I added bill_item[update][#{id}]
[id] just in case)
The param received is:
{"commit"=>"Save",
2011 Feb 02
11
How to include the Scope(...) in a generated string?
I''d like to include similar information that notice() spits out in a
file I am generating -- basically so that anyone looking at the
generated file (actually a file fragment) could trace it back to the
class that is generating the entry.
Using $name within the file fragment is the closest I am getting to
what I want -- is there anything better?
--
You received this message because you
2006 Oct 30
3
Question about new results hash
Is it really a hash? As in, can I pass it into a method that a worker is
calling so that, for example, a method in my ActiveRecord that''s
actually doing the work?
Really liking the new code. Does rubyforge or devjavu have the rdocs
anywhere?
--
Joshua Warchol
Code Poet, Zaadz Inc.
http://joshua.zaadz.com/
2003 May 15
6
Question on LDAP+Samba+PDC
Hello everyone.
Well, I have been working very hard lately, trying to get a server up to
act as our Samba PDC with LDAP. So far, everything seems to be working
well. I've been able to get samba 2.2.8 and openldap 2.0.27 installed with
no problems. I've setup my config files (ldap.conf, slapd.conf, smb.conf)
as well as added some initial entries to the LDAP directory.
I've been
2012 Jun 01
3
Serialized attribute saved as HashWithIndifferentAccess in database
My Booking model has: serialize :custom_data, Hash
From the console it works as expected saving values to the custom_data
attribute.
But when having a form with parameters like
this: booking[custom_data][hello] and creating a new object in the
controller like this: Booking.new( params[:booking] ), values are saved in
the database with added metadata like this: ---
2009 Apr 24
4
uninitialized constant Facter::IPAddress (NameError)
I just started getting this error on some machines after a yum update
from centos 5.2 to centos 5.3. Does anyone know what it means? Since
I''m not a ruby person, I''m not sure how to debug this, but it looks to
me like facter is having trouble parsing information about my
interfaces.
# facter
/usr/lib/ruby/site_ruby/1.8/facter/ipmess.rb:19: uninitialized constant