similar to: rspec: identical tests fails when repeated

Displaying 20 results from an estimated 5000 matches similar to: "rspec: identical tests fails when repeated"

2010 Jun 02
5
user routing versus admin routing strategies?
In an app where ordinary users are limited to viewing and editing their own "stuff", but someone with admin privs can view and edit anybody''s stuff, what''s the right strategy for routing? At first blush, I''d think that an ordinary user (e.g. with id 565) should see something like: http://example.com/mystuff.html ... where the controller assumes
2012 Oct 09
8
unexpected should_receive behaviour
Hi, surely I''m missing something... but what!? in my spec I''ve User.should_receive(:find).with("1").and_return(@user) and in my controller User.find(params[:id]) green light... correct... but if I change my controller using another method, for example first: User.first or even User.all I get green light too... I was expecting an error like expected: 1 time
2013 Nov 22
2
Cancan Rspec load_and_authorize_resource
Hello! While running bundle exec rake, I receive following error (see in attached file) However, my tests are steel passing with command rspec spec/controllers/ Some info: ads_controller.rb: class AdsController < ApplicationController load_and_authorize_resource except: :create end ads_controller_spec.rb: require ''spec_helper'' describe AdsController do render_views
2012 Mar 30
1
cancan breaks scoped mass assignment
Hi all, I just installed cancan on a new project and found out that it creates some problems with the new scoped mass assignment features of rails 3.2 . Basically, in my User model I create some attr_accessible attributes in order to avoid users to edit their roles or other sensitive information. From the administration I allow admins to edit those protected attributes by passing
2010 Apr 20
5
Spring Cleaning
Right now in my view, I have a whole HUGE clump of <% if current_user %> and then <% if current_admin %> and then <% if current_teacher %> and then all that other stuff in my view. I have a ginourmous chunk of if and else statements in my views... is there a way to make it prettier? The if and else''s almost all have the same functions, expect for some minor changes.
2011 Nov 28
4
getting a subdomain name in model.
Hi all, I am facing problem in getting subdomain name inside the model. The following is my setup. I am using cancan for authorization.I wanted a specific condition in Ability.rb ( the file which is placed in models if we install cancan gem). Below is the condition I wanted: ========================================================= user ||= User.new # guest user (not logged in) if
2010 Nov 24
1
NameError in Devise/sessionsController#new
I created a sample application. Added devise in it, it works fine. Then added cancan gem into it. Created an ability class. define some permissions. Then added line load_and_authorize_resource to the Application Controller, after that when i go to the page http://0.0.0.0:3000/users/sign_in it gave the following error, NameError in Devise/sessionsController#new uninitialized constant Session
2011 Jan 15
3
respond_with javascript
My ajax stopped working when I switched to using respond_with. For my Votes, I have the create action and the corresponding create.js.erb, and respond_to :html, :js, :xml in the controller. Heres the log when I try and create a vote: Started POST "/stories/3-asdfasdf1111/votes" for 127.0.0.1 at Fri Jan 14 20:46:36 -0800 2011 Processing by VotesController#create as */* Parameters:
2011 Feb 16
3
stubbing gets undone?
I''m looking at an example where a stub seems to work sometimes, and sometimes appears to become "unstubbed". I haven''t boiled it down to a minimal example, but it goes something like this: ---- the model: class Premise << ActiveRecord::Base def lookup_stuff_on_the_web $stderr.puts("entering lookup_stuff_on_the_web with #{self}") ... end end
2011 Jun 05
1
Cancan redirect back at AccessDenied
Hello I have a rails 3 app and I am trying to implement the redirect back action at access denied for cancan. If I try this in my application_controller: rescue_from CanCan::AccessDenied do |exception| redirect_to :back end It gives the following error: No HTTP_REFERER was set in the request to this action, so redirect_to :back could not be called successfully. If this is a test, make sure
2013 Feb 25
7
Optimistic Locking Enhancements: Gem or Core?
I''m working on an app that makes use of rails'' optimistic locking feature and seeing some possibilities for improvements. It seems a bit tedious to have to add :lock_version to forms wherever the model is used. You also have to "hack" around rails'' UJS feature to add it as a URL parameter when using remote: true, method: [:put, :patch, :post, :delete].
2011 Mar 01
6
render :collection calling partial with phantom object?
I have two models with a straightforward has_many / belongs_to relationship: class Premise < ActiveRecord::Base has_many :metered_services, :dependent => :destroy ... end class MeteredService < ActiveRecord::Base belongs_to :premise ... end and nested routes to match: Demo::Application.routes.draw do devise_for :users resources :premises do resources :metered_services
2009 Feb 28
7
be_valid (validates_format_of ..., :on => :create)
Greetings, How to write Example which will check if model''s variable''s format is valid using :on => :create, like this: class User < ActiveRecord::Base ... validates_format_of :email, :with => /.../, :on => :create ... Using following code is not right: it "should ..." do @user = users(:example_user) @user.email =
2006 Jun 02
6
Set instance variable for all actions in the Controller
Can I set an application wide instance variable that is available for all actions...and their views? eg. class ApplicationController < ActionController::Base @current_user = User.find(session[:user_id]) end and everywhere I can call @current_user.id and I can get that object? Even down in the views? I could not get this to work... Thanks in advance, Jeff -------------- next part
2006 Mar 16
6
Sessions or lookups?
My application needs to know if a user is an administrator, for security and aesthetic reasons. At the moment, I store true/false in the session by doing the following at login: session[:user_is_admin] = authenticated_user.is_admin? Is this OK to do? Or should I really be doing the following every time: User.find(session[:user_id]).is_admin? (user_id is always in the session too) Is there
2008 Jan 30
2
Where can I get "authenticate_with_http_basic"?
Hi, I just installed Rails 2.0.2 [root@mymachine easyx]# ruby --version ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-linux] [root@mymachine easyrx]# gem install rails --include-dependencies Need to update 16 gems from http://gems.rubyforge.org ................ complete Successfully installed rails-2.0.2 [root@remandev easyrx]# But I''m getting this error in my restful_authentication
2003 Nov 01
4
NAT router and off-premise SIP audio problem
Our network is connected to a cablemodem using a dynamic DNS service to resolve our address. The Asterisk server has been alternately set up behind a NAT router and without a NAT router -- that is, with two NICs, one of which is providing NAT to the rest of the network; the office SIPs are behind that with static private IP addresses. Off-premise SIPs are all behind simple NAT routers.
2006 Jul 16
9
acl_system help is needed
i found Ezra''s acl_system plugin yesterday and i am trying to figure it out. based on the simple instructions on the site, it does exactly what i need but i''m getting some errors when i try to use it: NoMethodError in UsersController#index You have a nil object when you didn''t expect it! The error occured while evaluating nil.roles i am pretty new to rails and
2009 Jan 16
3
rspec model testing - test on user defined validation- How do I test that the create failed.
I''m new to rspec and looking for way to test a validation I added to a model. The test checks to see that if field1 has a value then field2 must be nil and vice versa. ------------------------------- When I did the rspec_scaffold it generated one test which worked before :each do @valid_attributes = { :field1 = "value for field1" :field2 = "value for
2012 Aug 28
4
ArgumentError in HomeController#index
Hey guys, I''m new to ruby/rails and trying to sort something... I just created an app with composer, http://railsapps.github.com/rails-composer/ I used the command: rails new myapp -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb I set up the rails server, and tried to load the app on localhost:3000 However, I end up with: ArgumentError in HomeController#index