similar to: Database transactions

Displaying 20 results from an estimated 3000 matches similar to: "Database transactions"

2006 Feb 27
1
Functional test problem with environments variables
Hi guys, i have been experiencing this problem once i put in some constant declarations in /config/environments/development.rb. I declared it very normally like this : USER_DETAILS = { :name => ''abc'', :password => ''123''} it works in the controller and when i run the application, i managed to get the values out from the development.rb by using some
2006 Nov 22
3
Controller Isolation
Hi, I have a project that I had running under rspec 0.6.x and recently upgraded to 0.7.2. I am trying to isolate my controllers from the database as I go through and change all the specs to run under 0.7.2. I am having a problem where I need to make the create! method return the mocked object as well as raise RecordInvalid exception. Is this at all possible? I use the rescue statement in my
2006 Mar 29
2
save related models from one form
I have three tables customers, indentities and people. I hav ecreated models for them. The are connected with foreign keys and has_many/belongs_to in this fashion: customers has_many: identities identities belongs_to: customer identities has_many: people people belongs_to: identities Now, I have a form in which I would like to create db entries for the three tables. customers have a password
2005 Mar 31
4
Transactions
I cant seem to find much information apart from the basics on transactions in rails. I have 5 nested transactions, and am performing the following basic operations: @whatever1.transaction do @whatever2.transaction do .... @whatever2.something = "foo" @whatever1.something = "bar" @whatever1.save @whatever2.save ..... end end ((( I had tried using
2010 Sep 01
5
validation errors bring up stack trace error page
hello! I made some custom validations for my app, which do catch invalid data in the console. However, when I enter invalid data through a form on the browser view, I get your stack trace error style page (similar to what you see when you get a syntax error or a nil object) instead of the nicely styled error messages (what you would see in a scaffolded application. First off, what is the stack
2006 Oct 06
1
transactions not work for array?
Hi, I have a transaction block as follow: begin Hello.transaction(input1,input2) input1.save for i in 0 to count input2[i].input1_id = input1.id input2[i].save end end rescue end I have used validates_uniqueness_of for input2 in the model The problem is, when there is duplicate record in input2, input1 and the first record in input2
2007 May 20
9
How to test for exceptions
Hi folks, I''m in the process of converting a Test::Unit functional test to RSpec, but I''ve run into a slight problem. I tried looking through the documentation but I still don''t know what I missed. Thanks in advance, Blake describe VenuesController, "on update" do before(:each) do @venue = mock("venue")
2006 Apr 16
5
Granular model validation based around controller actions?
How can I achieve granular control over the validation for different controllers? I create users from an administration controller, but I don''t want to fill in all their information fields, just have their name and email address. When they accept the invitation, I want to implement validation on the other fields. I have looked at using :on => :update, but I would have to make the
2009 Sep 15
1
R Memory Usage Concerns
Hello all, To start with, these measurements are on Linux with R 2.9.2 (64-bit build) and Python 2.6 (also 64-bit). I've been investigating R for some log file analysis that I've been doing. I'm coming at this from the angle of a programmer whose primarily worked in Python. As I've been playing around with R, I've noticed that R seems to use a *lot* of memory, especially
2009 Jul 04
12
save! not allowed after validates_uniqueness
I have this in a model validates_uniqueness_of :aspect, :scope => :user_id In an instance method of the same model I have "save!" but I don''t touch the :aspect attribute in that instance method at all. Whenever that save! command is run however I get this error: ActiveRecord::RecordInvalid: Validation failed: Aspect has already been taken I don''t
2007 Aug 08
5
Can''t seem to spec a ActiveRecord::RecordInvalid exception properly...
1 def create 2 @user = User.new(params[:user]) 3 @user.save! 4 self.current_user = @user 5 redirect_to user_path(@user) 6 flash[:notice] = "Thanks for signing up!" 7 rescue ActiveRecord::RecordInvalid 8 render :action => ''new'' 9 end I can''t seem to properly spec this out. I am trying numerous things, the latest one is
2007 Sep 13
2
Failing to raise an exception in a stub
I''ve come across rather strange behaviour when trying to raise an exception in a stubbed method. I''m speccing the behaviour of a Rails create action, where I''m using save! to catch failed saves. In the case of working save, I''m using the following stub: @client.stub!(:save!).and_return(true) which works fine. However, in the negative case,
2005 May 08
3
sqlite, views, incorrect data types?
This has been driving me crazy for a few days now. I am using sqlite3 however I have also found this to be the case with 2.8.15: I have data types text or integer on every column of every table in the database. Now i know sqlite doesnt care much about data types, but I believe rails does (correct me if im wrong). On pages that query a table, everything is perfect. BUT when I use a view
2007 Nov 17
7
Down with Lambda!!
Rspec is all about using natural language to define behavior. In this context, I feel that lambda is sorely out of place. I was chatting on #irc and a pal of mine (wycats) proposed an interesting alternative: alias_method :doing, :lambda so instead of something like lambda {post :create, {:title => nil}}.should raise_error(ActiveRecord::RecordInvalid) we get doing {post :create, {:title
2011 Sep 01
2
Custom ActiveRecord Error Message
I''m generating 3 models on 1 controller and i''m rescuing ActiveRecord::RecordInvalid for validation errors, however 2 of the models have the same attribute called "name", and if there''s an error on that field, I wouldn''t know whether that belongs to model A or model B. What then is the best way of modifying the error message of a validation error
2007 Aug 07
4
Problems with raising errors on a mocked object
I''m trying to mock a object to raise a certain error. By doing so I get a ArgumentError on ActiveRecord''s save! method: http://pastie.caboo.se/85628 I''ve tried to debug it but just can''t seem to find what I''m doing wrong. Any help is greatly appreciated. Cheers, Eivind Uggedal
2006 Oct 08
9
Organizing tests and mocha expectations
I''m simultaneously getting into using Mocha and RSpec-style tests (courtesy of the simply_bdd plugin) and I''m struggling with some issues while trying to organize my specs/test. Here''s a code example illustrating the problem: context "update cliient invalid data" do include ClientsControllerSpecHelper specify "should render edit form" do
2007 May 22
3
Comments wanted about spec''ing out a couple controller methods
(oops, accidentally sent this to the rspec-devel list, sorry about that) Could someone help me spec out these Rails controller methods? I don''t know where to get started, especially with the transaction stuff. Or, if anyone else could suggest ways I could improve the code, that would be great as well. Puzzle has_one Media. Both are AR model objects. class PuzzlesController <
2009 Jan 30
2
rescue ActiveRecord::RecordInvalid
Hi all, I am using is_attachment plugin, but I will always end up with this error: RuntimeError in PostsController#create BLAH which was caused by: version.filename = file_name_for_version(version_name) begin version.save! rescue ActiveRecord::RecordInvalid raise "BLAH" end end RecordInvalid was raised by save! because is invalid. Does anyone know why? I am uploading
2006 Mar 19
2
Functional Testing
Hey all, I have a many-to-many relationship (Questions has_and_belongs_to_many Answers), and when I destroy the Question (the one) I also destroy all the Answers (the many). Since the following doesn''t seem to work for has_and_belongs_to_many: class Question < AR::Base... has_and_belongs_to_many :answers, :dependent => :destroy end I have this embedded in a transaction block