Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Several errors #6

Closed
mazharoddin opened this issue Jun 2, 2015 · 10 comments
Closed

Several errors #6

mazharoddin opened this issue Jun 2, 2015 · 10 comments

Comments

@mazharoddin
Copy link

There are several errors in sample code, both blorgh and subscribem code has several errors..can you please help me in fixing these errors

@radar
Copy link
Owner

radar commented Jun 8, 2015

@mazharoddin Saying that there are "several errors" in a 50,000 word book isn't that helpful to the author. What errors? Can you please let me know what these are and on what pages they're on?

@mazharoddin
Copy link
Author

hi, I apologize, what I mean is I came across several errors while following the book and even provided sample code has similar errors, any way find below for the errors from the sample code.

  13) User signup under an account
     Failure/Error: click_button "Sign up"
     ActionView::Template::Error:
       undefined method `owner?' for nil:NilClass
----------
-----
----
Finished in 23.19 seconds (files took 2.28 seconds to load)
25 examples, 13 failures, 2 pending

Failed examples:

rspec ./spec/controllers/subscribem/accounts_controller_spec.rb:15 # Subscribem::AccountsController creates the account's schema should receive create_schema(*(any args)) 1 time
rspec ./spec/features/accounts/scoping_spec.rb:16 # Account scoping displays only account A's records
rspec ./spec/features/accounts/scoping_spec.rb:23 # Account scoping displays only account B's records
rspec ./spec/features/accounts/sign_up_spec.rb:4 # Accounts creating an account
rspec ./spec/features/accounts/updating_spec.rb:15 # Accounts as the account owner updating an account
rspec ./spec/features/accounts/updating_spec.rb:24 # Accounts as the account owner updating an account with invalid attributes fails
rspec ./spec/features/accounts/updating_spec.rb:64 # Accounts as the account owner with plans updating an account's plan
rspec ./spec/features/accounts/updating_spec.rb:114 # Accounts as the account owner with plans can't change account's plan with invalid credit card number
rspec ./spec/features/accounts/updating_spec.rb:143 # Accounts as the account owner with plans changing plan after initial subscription
rspec ./spec/features/accounts/updating_spec.rb:160 # Accounts as the account owner with plans changing plan after initial subscription fails
rspec ./spec/features/accounts/updating_spec.rb:182 # Accounts as a user cannot edit an account's information
rspec ./spec/features/users/sign_in_spec.rb:12 # User sign in signs in as an account owner successfully
rspec ./spec/features/users/sign_up_spec.rb:8 #  

@radar
Copy link
Owner

radar commented Jun 17, 2015

Can you please share the link to your repo which contains this code?

@mazharoddin
Copy link
Author

Hi Ryan,
Please find below for bitbucket repositories.
[email protected]:mazharoddin/subscribem.git
[email protected]:mazharoddin/blorgh.git

Apart from rspec errors, newly created subdomain user won't login automatically after creating subdomain, and when I try to login manually then I am getting below error.

undefined local variable or method `edit_account_path' for
 <div class='row'>
<div class= pull-right'>
<%= render "subscribem/shared/login" %>
</div>
</div>
<div class='row'>

I tried with your repository code aswell, let me re-try and update accordingly.
Thanks

@mazharoddin
Copy link
Author

Hi Ryan,
I am getting below error while trying to signup using your repository code.

ActionController::InvalidAuthenticityToken
Rails.root: /home/mazhar/Documents/Rails/development/saas_book_examples/blorgh

Application Trace | Framework Trace | Full Trace
actionpack (4.2.2) lib/action_controller/metal/request_forgery_protection.rb:181:in `handle_unverified_request'
actionpack (4.2.2) lib/action_controller/metal/request_forgery_protection.rb:209:in `handle_unverified_request'
actionpack (4.2.2) lib/action_controller/metal/request_forgery_protection.rb:204:in `verify_authenticity_token'
activesupport (4.2.2) lib/active_support/callbacks.rb:432:in `block in make_lambda'
activesupport (4.2.2) lib/active_support/callbacks.rb:164:in `call'
activesupport (4.2.2) lib/active_support/callbacks.rb:164:in `block in halting'
activesupport (4.2.2) lib/active_support/callbacks.rb:504:in `call'
activesupport (4.2.2) lib/active_support/callbacks.rb:504:in `block in call'
activesupport (4.2.2) lib/active_support/callbacks.rb:504:in `each'
activesupport (4.2.2) lib/active_support/callbacks.rb:504:in `call'
activesupport (4.2.2) lib/active_support/callbacks.rb:92:in `_run_callbacks'
activesupport (4.2.2) lib/active_support/callbacks.rb:776:in `_run_process_action_callbacks'
activesupport (4.2.2) lib/active_support/callbacks.rb:81:in `run_callbacks'

If i try to run test cases in 'subscribem' engine, I am getting below errors.

Finished in 23.29 seconds (files took 1.72 seconds to load)
25 examples, 13 failures, 2 pending

Failed examples:

rspec ./spec/controllers/subscribem/accounts_controller_spec.rb:15 # Subscribem::AccountsController creates the account's schema should receive create_schema(*(any args)) 1 time
rspec ./spec/features/accounts/scoping_spec.rb:16 # Account scoping displays only account A's records
rspec ./spec/features/accounts/scoping_spec.rb:23 # Account scoping displays only account B's records
rspec ./spec/features/accounts/sign_up_spec.rb:4 # Accounts creating an account
rspec ./spec/features/accounts/updating_spec.rb:15 # Accounts as the account owner updating an account
rspec ./spec/features/accounts/updating_spec.rb:24 # Accounts as the account owner updating an account with invalid attributes fails
rspec ./spec/features/accounts/updating_spec.rb:64 # Accounts as the account owner with plans updating an account's plan
rspec ./spec/features/accounts/updating_spec.rb:114 # Accounts as the account owner with plans can't change account's plan with invalid credit card number
rspec ./spec/features/accounts/updating_spec.rb:143 # Accounts as the account owner with plans changing plan after initial subscription
rspec ./spec/features/accounts/updating_spec.rb:160 # Accounts as the account owner with plans changing plan after initial subscription fails
rspec ./spec/features/accounts/updating_spec.rb:182 # Accounts as a user cannot edit an account's information
rspec ./spec/features/users/sign_in_spec.rb:12 # User sign in signs in as an account owner successfully
rspec ./spec/features/users/sign_up_spec.rb:8 # User signup under an account

 1) Subscribem::AccountsController creates the account's schema should receive create_schema(*(any args)) 1 time
     Failure/Error: expect(account).to receive(:create_schema)
       (#<Subscribem::Account:0x00000003e012c8>).create_schema(*(any args))
           expected: 1 time with any arguments
           received: 0 times with any arguments
     # ./spec/controllers/subscribem/accounts_controller_spec.rb:16:in `block (3 levels) in <top (required)>'

  2) Account scoping displays only account A's records
     Failure/Error: visit main_app.things_url(:subdomain => account_a.subdomain)
     NoMethodError:
       undefined method `id' for nil:NilClass

@radar
Copy link
Owner

radar commented Jun 20, 2015

The sass_book_examples repo was broken. I apologise for that. Here's the commit that fixed it: 211adde.

That's been plaguing me for 6 months and I sat down today to figure it out, and I managed to do that.


Onto your repo. I am seeing different errors than you're reporting. I will address the ones I can see.

First thing: You need to remove spec/support/factories because it redefines the user factory which is already defined in lib/subscribem/testing_support.

Second thing: Remove spec/controllers/things_controller.rb because it isn't testing anything useful and is showing an error in your RSpec output.

Third thing: The updating spec in your tests is failing because you have two "Change plan" buttons... so the test says on my machine.


Where are you seeing those errors that you reported? Which repo?

@mazharoddin
Copy link
Author

Sure, I will use your latest commit, thanks for your time.

I am running rspec using the repo which I pasted ([email protected]:mazharoddin/subscribem.git
[email protected]:mazharoddin/blorgh.git), let me re-clone them and try to re-run.
I will update you once I re-try as you suggested.
Thanks

@mazharoddin
Copy link
Author

Hi Ryan,
Sorry for the delay in reply, got struck with office work.
Today I re cloned [email protected]:radar/saas_book_examples.git repository and tried to test sign up functionality. Signup was successful, but later I am getting below error while signing in using below link.

   xxx.vcap.me:3000/sign_in

   Showing  saas_book_examples/subscribem/app/views/subscribem/shared/_login.html.erb where   line #5 raised:

   undefined local variable or method `account_path' for    #<#<Class:0x007f31d8cd1d18>:0x007f31d8cd1228>
Extracted source (around line #15):              
    <div class='row'>
      <div class='pull-right'>
        <%= render "subscribem/shared/login" %>
      </div>
    </div>
    <div class='row'>

Trace of template inclusion: app/views/layouts/application.html.erb

Steps to recreate.

  1. access app using www.vcap.me:3000 and complete the sign-up.
  2. App will complete sign-up process successfully and displays my blog page heading.
  3. Try to access posts using xxx.vcap.me:3000/posts , will get below error while doing so.
undefined method `id' for nil:NilClass
Extracted source (around line #3):
class PostsController < ApplicationController
def index
@posts = Post.scoped_to(current_account)
end
def show

Rails.root: /saas_book_examples/blorgh
Application Trace | Framework Trace | Full Trace

app/controllers/posts_controller.rb:3:in `index'
  1. later try to access sign-in using this link xxx.vcap.me:3000. Will see another error on account_path as I mentioned above.
 Showing /home/mazhar/Documents/Rails/development/saas_book_examples/subscribem/app/views/subscribem/shared/_login.html.erb where line #5 raised:
undefined local variable or method `account_path' for #<#<Class:0x007fb844072d68>:0x007fb864b40ef0>

Extracted source (around line #15):
<div class='row'>
<div class='pull-right'>
<%= render "subscribem/shared/login" %>
</div>
</div>
<div class='row'>

Trace of template inclusion: app/views/layouts/application.html.erb

Rails.root: /saas_book_examples/blorgh
Application Trace | Framework Trace | Full Trace

app/views/layouts/application.html.erb:15:in `_app_views_layouts_application_html_erb___83292067429723261_70214968463620'

One great news is, all test cases from subscribem engine are passing with your latest check-in.

mazhar@oc7832456538 subscribem]$ rspec 
......................
Finished in 19.33 seconds (files took 5.94 seconds to load)
22 examples, 0 failures

Please let me know if any further details are needed.
Thanks.

@radar
Copy link
Owner

radar commented Jun 30, 2015

Hi @mazharoddin, please format your post with GitHub formatting to make it easier to read.

@mazharoddin
Copy link
Author

Hi Ryan,
Formatted comments as suggested.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants