mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-24 16:58:35 -04:00
rename account details to just account
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
||||
@@ -1,46 +0,0 @@
|
||||
class AccountDetailsController < ApplicationController
|
||||
load_and_authorize_resource
|
||||
# GET /account_details
|
||||
# GET /account_details.json
|
||||
def index
|
||||
@account_details = AccountDetail.all
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @account_details }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /account_details/1
|
||||
# GET /account_details/1.json
|
||||
def show
|
||||
@account_detail = AccountDetail.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.json { render json: @account_detail }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /account_details/1/edit
|
||||
def edit
|
||||
@account_detail = AccountDetail.find(params[:id])
|
||||
end
|
||||
|
||||
# PUT /account_details/1
|
||||
# PUT /account_details/1.json
|
||||
def update
|
||||
@account_detail = AccountDetail.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if @account_detail.update_attributes(params[:account_detail])
|
||||
format.html { redirect_to @account_detail, notice: 'Account detail was successfully updated.' }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.html { render action: "edit" }
|
||||
format.json { render json: @account_detail.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
46
app/controllers/accounts_controller.rb
Normal file
46
app/controllers/accounts_controller.rb
Normal file
@@ -0,0 +1,46 @@
|
||||
class AccountsController < ApplicationController
|
||||
load_and_authorize_resource
|
||||
# GET /accounts
|
||||
# GET /accounts.json
|
||||
def index
|
||||
@accounts = Account.all
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @accounts }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /accounts/1
|
||||
# GET /accounts/1.json
|
||||
def show
|
||||
@account = Account.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.json { render json: @account }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /accounts/1/edit
|
||||
def edit
|
||||
@account = Account.find(params[:id])
|
||||
end
|
||||
|
||||
# PUT /accounts/1
|
||||
# PUT /accounts/1.json
|
||||
def update
|
||||
@account = Account.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if @account.update_attributes(params[:account])
|
||||
format.html { redirect_to @account, notice: 'Account detail was successfully updated.' }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.html { render action: "edit" }
|
||||
format.json { render json: @account.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,2 +0,0 @@
|
||||
module AccountDetailsHelper
|
||||
end
|
||||
@@ -16,7 +16,7 @@ class Ability
|
||||
# and nobody should be able to view this except admins
|
||||
cannot :read, Role
|
||||
cannot :read, Product
|
||||
cannot :read, AccountDetail
|
||||
cannot :read, Account
|
||||
cannot :read, AccountType
|
||||
|
||||
if member
|
||||
@@ -98,8 +98,8 @@ class Ability
|
||||
|
||||
# admins can read and manage members' account details (paid acct
|
||||
# status, etc)
|
||||
can :read, AccountDetail
|
||||
can :manage, AccountDetail
|
||||
can :read, Account
|
||||
can :manage, Account
|
||||
can :read, AccountType
|
||||
can :manage, AccountType
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class AccountDetail < ActiveRecord::Base
|
||||
class Account < ActiveRecord::Base
|
||||
attr_accessible :account_type_id, :member_id, :paid_until
|
||||
belongs_to :member
|
||||
belongs_to :account_type
|
||||
@@ -12,7 +12,7 @@ class Member < ActiveRecord::Base
|
||||
has_many :sent_notifications, :foreign_key => 'sender_id'
|
||||
has_many :authentications
|
||||
has_many :orders
|
||||
has_one :account_detail
|
||||
has_one :account
|
||||
|
||||
default_scope order("lower(login_name) asc")
|
||||
scope :confirmed, where('confirmed_at IS NOT NULL')
|
||||
@@ -69,10 +69,10 @@ class Member < ActiveRecord::Base
|
||||
# Give each new member a default garden
|
||||
after_create {|member| Garden.create(:name => "Garden", :owner_id => member.id) }
|
||||
|
||||
# and an account details record
|
||||
# and an account record (for paid accounts etc)
|
||||
# we use find_or_create to avoid accidentally creating a second one,
|
||||
# which can happen sometimes especially with FactoryGirl associations
|
||||
after_create {|member| AccountDetail.find_or_create_by_member_id(:member_id => member.id) }
|
||||
after_create {|member| Account.find_or_create_by_member_id(:member_id => member.id) }
|
||||
|
||||
# allow login via either login_name or email address
|
||||
def self.find_first_by_auth_conditions(warden_conditions)
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
%h1 Editing account_detail
|
||||
|
||||
= render 'form'
|
||||
|
||||
= link_to 'Show', @account_detail
|
||||
\|
|
||||
= link_to 'Back', account_details_path
|
||||
@@ -1,23 +0,0 @@
|
||||
%h1 Listing account_details
|
||||
|
||||
%table
|
||||
%tr
|
||||
%th Member
|
||||
%th Account type
|
||||
%th Paid until
|
||||
%th
|
||||
%th
|
||||
%th
|
||||
|
||||
- @account_details.each do |account_detail|
|
||||
%tr
|
||||
%td= account_detail.member_id
|
||||
%td= account_detail.account_type
|
||||
%td= account_detail.paid_until
|
||||
%td= link_to 'Show', account_detail
|
||||
%td= link_to 'Edit', edit_account_detail_path(account_detail)
|
||||
%td= link_to 'Destroy', account_detail, :method => :delete, :data => { :confirm => 'Are you sure?' }
|
||||
|
||||
%br
|
||||
|
||||
= link_to 'New Account detail', new_account_detail_path
|
||||
@@ -1,5 +0,0 @@
|
||||
%h1 New account_detail
|
||||
|
||||
= render 'form'
|
||||
|
||||
= link_to 'Back', account_details_path
|
||||
@@ -1,18 +0,0 @@
|
||||
%p#notice= notice
|
||||
|
||||
%p
|
||||
%b Member:
|
||||
= @account_detail.member_id
|
||||
%p
|
||||
%b Account type:
|
||||
- if @account_detail.account_type
|
||||
= @account_detail.account_type.name
|
||||
- else
|
||||
Free account
|
||||
%p
|
||||
%b Paid until:
|
||||
= @account_detail.paid_until
|
||||
|
||||
= link_to 'Edit', edit_account_detail_path(@account_detail)
|
||||
\|
|
||||
= link_to 'Back', account_details_path
|
||||
@@ -1,9 +1,9 @@
|
||||
= form_for @account_detail do |f|
|
||||
- if @account_detail.errors.any?
|
||||
= form_for @account do |f|
|
||||
- if @account.errors.any?
|
||||
#error_explanation
|
||||
%h2= "#{pluralize(@account_detail.errors.count, "error")} prohibited this account_detail from being saved:"
|
||||
%h2= "#{pluralize(@account.errors.count, "error")} prohibited this account from being saved:"
|
||||
%ul
|
||||
- @account_detail.errors.full_messages.each do |msg|
|
||||
- @account.errors.full_messages.each do |msg|
|
||||
%li= msg
|
||||
|
||||
.field
|
||||
7
app/views/accounts/edit.html.haml
Normal file
7
app/views/accounts/edit.html.haml
Normal file
@@ -0,0 +1,7 @@
|
||||
%h1 Editing account
|
||||
|
||||
= render 'form'
|
||||
|
||||
= link_to 'Show', @account
|
||||
\|
|
||||
= link_to 'Back', accounts_path
|
||||
23
app/views/accounts/index.html.haml
Normal file
23
app/views/accounts/index.html.haml
Normal file
@@ -0,0 +1,23 @@
|
||||
%h1 Listing accounts
|
||||
|
||||
%table
|
||||
%tr
|
||||
%th Member
|
||||
%th Account type
|
||||
%th Paid until
|
||||
%th
|
||||
%th
|
||||
%th
|
||||
|
||||
- @accounts.each do |account|
|
||||
%tr
|
||||
%td= account.member_id
|
||||
%td= account.account_type
|
||||
%td= account.paid_until
|
||||
%td= link_to 'Show', account
|
||||
%td= link_to 'Edit', edit_account_path(account)
|
||||
%td= link_to 'Destroy', account, :method => :delete, :data => { :confirm => 'Are you sure?' }
|
||||
|
||||
%br
|
||||
|
||||
= link_to 'New Account detail', new_account_path
|
||||
5
app/views/accounts/new.html.haml
Normal file
5
app/views/accounts/new.html.haml
Normal file
@@ -0,0 +1,5 @@
|
||||
%h1 New account
|
||||
|
||||
= render 'form'
|
||||
|
||||
= link_to 'Back', accounts_path
|
||||
18
app/views/accounts/show.html.haml
Normal file
18
app/views/accounts/show.html.haml
Normal file
@@ -0,0 +1,18 @@
|
||||
%p#notice= notice
|
||||
|
||||
%p
|
||||
%b Member:
|
||||
= @account.member_id
|
||||
%p
|
||||
%b Account type:
|
||||
- if @account.account_type
|
||||
= @account.account_type.name
|
||||
- else
|
||||
Free account
|
||||
%p
|
||||
%b Paid until:
|
||||
= @account.paid_until
|
||||
|
||||
= link_to 'Edit', edit_account_path(@account)
|
||||
\|
|
||||
= link_to 'Back', accounts_path
|
||||
@@ -1,14 +1,5 @@
|
||||
Growstuff::Application.routes.draw do
|
||||
|
||||
resources :account_types
|
||||
|
||||
|
||||
resources :account_details
|
||||
|
||||
|
||||
resources :order_items
|
||||
|
||||
|
||||
devise_for :members, :controllers => { :registrations => "registrations" }
|
||||
|
||||
resources :authentications
|
||||
@@ -22,8 +13,13 @@ Growstuff::Application.routes.draw do
|
||||
resources :roles
|
||||
resources :forums
|
||||
resources :notifications
|
||||
|
||||
# everything for paid accounts etc
|
||||
resources :account_types
|
||||
resources :accounts
|
||||
resources :orders
|
||||
match 'orders/:id/complete' => 'orders#complete', :as => 'complete_order'
|
||||
resources :order_items
|
||||
resources :products
|
||||
|
||||
get "home/index"
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
class RenameAccountDetailToAccount < ActiveRecord::Migration
|
||||
def change
|
||||
rename_table :account_details, :accounts
|
||||
end
|
||||
|
||||
end
|
||||
18
db/schema.rb
18
db/schema.rb
@@ -11,15 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20130518000339) do
|
||||
|
||||
create_table "account_details", :force => true do |t|
|
||||
t.integer "member_id", :null => false
|
||||
t.integer "account_type_id"
|
||||
t.datetime "paid_until"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
ActiveRecord::Schema.define(:version => 20130518002942) do
|
||||
|
||||
create_table "account_types", :force => true do |t|
|
||||
t.string "name", :null => false
|
||||
@@ -29,6 +21,14 @@ ActiveRecord::Schema.define(:version => 20130518000339) do
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "accounts", :force => true do |t|
|
||||
t.integer "member_id", :null => false
|
||||
t.integer "account_type_id"
|
||||
t.datetime "paid_until"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "authentications", :force => true do |t|
|
||||
t.integer "member_id", :null => false
|
||||
t.string "provider", :null => false
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe AccountDetailsController do
|
||||
|
||||
login_member(:admin_member)
|
||||
|
||||
def valid_attributes
|
||||
{ "paid_until" => Time.now }
|
||||
end
|
||||
|
||||
def create_account_detail
|
||||
# account details are automatically created when you create a new
|
||||
# member; creating them manually will just cause errors as only one is
|
||||
# allowed.
|
||||
|
||||
member = FactoryGirl.create(:member)
|
||||
return member.account_detail
|
||||
end
|
||||
|
||||
describe "GET index" do
|
||||
it "assigns all account_details as @account_details" do
|
||||
account_detail = create_account_detail
|
||||
get :index, {}
|
||||
# can't match the whole list because it includes the one for the
|
||||
# logged in admin member, sigh
|
||||
assigns(:account_details).should include(account_detail)
|
||||
assigns(:account_details).count.should eq 2
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET show" do
|
||||
it "assigns the requested account_detail as @account_detail" do
|
||||
account_detail = create_account_detail
|
||||
get :show, {:id => account_detail.to_param}
|
||||
assigns(:account_detail).should eq(account_detail)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET edit" do
|
||||
it "assigns the requested account_detail as @account_detail" do
|
||||
account_detail = create_account_detail
|
||||
get :edit, {:id => account_detail.to_param}
|
||||
assigns(:account_detail).should eq(account_detail)
|
||||
end
|
||||
end
|
||||
|
||||
describe "PUT update" do
|
||||
describe "with valid params" do
|
||||
it "updates the requested account_detail" do
|
||||
account_detail = create_account_detail
|
||||
# Assuming there are no other account_detail in the database, this
|
||||
# specifies that the AccountDetail created on the previous line
|
||||
# receives the :update_attributes message with whatever params are
|
||||
# submitted in the request.
|
||||
AccountDetail.any_instance.should_receive(:update_attributes).with({ "member_id" => "1" })
|
||||
put :update, {:id => account_detail.to_param, :account_detail => { "member_id" => "1" }}
|
||||
end
|
||||
|
||||
it "assigns the requested account_detail as @account_detail" do
|
||||
account_detail = create_account_detail
|
||||
put :update, {:id => account_detail.to_param, :account_detail => valid_attributes}
|
||||
assigns(:account_detail).should eq(account_detail)
|
||||
end
|
||||
|
||||
it "redirects to the account_detail" do
|
||||
account_detail = create_account_detail
|
||||
put :update, {:id => account_detail.to_param, :account_detail => valid_attributes}
|
||||
response.should redirect_to(account_detail)
|
||||
end
|
||||
end
|
||||
|
||||
describe "with invalid params" do
|
||||
it "assigns the account_detail as @account_detail" do
|
||||
account_detail = create_account_detail
|
||||
# Trigger the behavior that occurs when invalid params are submitted
|
||||
AccountDetail.any_instance.stub(:save).and_return(false)
|
||||
put :update, {:id => account_detail.to_param, :account_detail => { "member_id" => "invalid value" }}
|
||||
assigns(:account_detail).should eq(account_detail)
|
||||
end
|
||||
|
||||
it "re-renders the 'edit' template" do
|
||||
account_detail = create_account_detail
|
||||
# Trigger the behavior that occurs when invalid params are submitted
|
||||
AccountDetail.any_instance.stub(:save).and_return(false)
|
||||
put :update, {:id => account_detail.to_param, :account_detail => { "member_id" => "invalid value" }}
|
||||
response.should render_template("edit")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
91
spec/controllers/accounts_controller_spec.rb
Normal file
91
spec/controllers/accounts_controller_spec.rb
Normal file
@@ -0,0 +1,91 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe AccountsController do
|
||||
|
||||
login_member(:admin_member)
|
||||
|
||||
def valid_attributes
|
||||
{ "paid_until" => Time.now }
|
||||
end
|
||||
|
||||
def create_account
|
||||
# account details are automatically created when you create a new
|
||||
# member; creating them manually will just cause errors as only one is
|
||||
# allowed.
|
||||
|
||||
member = FactoryGirl.create(:member)
|
||||
return member.account
|
||||
end
|
||||
|
||||
describe "GET index" do
|
||||
it "assigns all accounts as @accounts" do
|
||||
account = create_account
|
||||
get :index, {}
|
||||
# can't match the whole list because it includes the one for the
|
||||
# logged in admin member, sigh
|
||||
assigns(:accounts).should include(account)
|
||||
assigns(:accounts).count.should eq 2
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET show" do
|
||||
it "assigns the requested account as @account" do
|
||||
account = create_account
|
||||
get :show, {:id => account.to_param}
|
||||
assigns(:account).should eq(account)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET edit" do
|
||||
it "assigns the requested account as @account" do
|
||||
account = create_account
|
||||
get :edit, {:id => account.to_param}
|
||||
assigns(:account).should eq(account)
|
||||
end
|
||||
end
|
||||
|
||||
describe "PUT update" do
|
||||
describe "with valid params" do
|
||||
it "updates the requested account" do
|
||||
account = create_account
|
||||
# Assuming there are no other account in the database, this
|
||||
# specifies that the Account created on the previous line
|
||||
# receives the :update_attributes message with whatever params are
|
||||
# submitted in the request.
|
||||
Account.any_instance.should_receive(:update_attributes).with({ "member_id" => "1" })
|
||||
put :update, {:id => account.to_param, :account => { "member_id" => "1" }}
|
||||
end
|
||||
|
||||
it "assigns the requested account as @account" do
|
||||
account = create_account
|
||||
put :update, {:id => account.to_param, :account => valid_attributes}
|
||||
assigns(:account).should eq(account)
|
||||
end
|
||||
|
||||
it "redirects to the account" do
|
||||
account = create_account
|
||||
put :update, {:id => account.to_param, :account => valid_attributes}
|
||||
response.should redirect_to(account)
|
||||
end
|
||||
end
|
||||
|
||||
describe "with invalid params" do
|
||||
it "assigns the account as @account" do
|
||||
account = create_account
|
||||
# Trigger the behavior that occurs when invalid params are submitted
|
||||
Account.any_instance.stub(:save).and_return(false)
|
||||
put :update, {:id => account.to_param, :account => { "member_id" => "invalid value" }}
|
||||
assigns(:account).should eq(account)
|
||||
end
|
||||
|
||||
it "re-renders the 'edit' template" do
|
||||
account = create_account
|
||||
# Trigger the behavior that occurs when invalid params are submitted
|
||||
Account.any_instance.stub(:save).and_return(false)
|
||||
put :update, {:id => account.to_param, :account => { "member_id" => "invalid value" }}
|
||||
response.should render_template("edit")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,15 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
# Specs in this file have access to a helper object that includes
|
||||
# the AccountDetailsHelper. For example:
|
||||
#
|
||||
# describe AccountDetailsHelper do
|
||||
# describe "string concat" do
|
||||
# it "concats two strings with spaces" do
|
||||
# helper.concat_strings("this","that").should == "this that"
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
describe AccountDetailsHelper do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
@@ -246,17 +246,17 @@ describe Ability do
|
||||
|
||||
context 'account details' do
|
||||
before(:each) do
|
||||
@account_detail = @member.account_detail
|
||||
@account = @member.account
|
||||
end
|
||||
|
||||
context 'ordinary member' do
|
||||
it "can't read account details" do
|
||||
@ability.should_not be_able_to(:read, @account_detail)
|
||||
@ability.should_not be_able_to(:read, @account)
|
||||
end
|
||||
it "can't manage account details" do
|
||||
@ability.should_not be_able_to(:create, AccountDetail)
|
||||
@ability.should_not be_able_to(:update, @account_detail)
|
||||
@ability.should_not be_able_to(:destroy, @account_detail)
|
||||
@ability.should_not be_able_to(:create, Account)
|
||||
@ability.should_not be_able_to(:update, @account)
|
||||
@ability.should_not be_able_to(:destroy, @account)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -269,12 +269,12 @@ describe Ability do
|
||||
end
|
||||
|
||||
it "can read account details" do
|
||||
@admin_ability.should be_able_to(:read, @account_detail)
|
||||
@admin_ability.should be_able_to(:read, @account)
|
||||
end
|
||||
it "can manage account details" do
|
||||
@admin_ability.should be_able_to(:create, AccountDetail)
|
||||
@admin_ability.should be_able_to(:update, @account_detail)
|
||||
@admin_ability.should be_able_to(:destroy, @account_detail)
|
||||
@admin_ability.should be_able_to(:create, Account)
|
||||
@admin_ability.should be_able_to(:update, @account)
|
||||
@admin_ability.should be_able_to(:destroy, @account)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe AccountDetail do
|
||||
describe Account do
|
||||
before(:each) do
|
||||
@member = FactoryGirl.create(:member)
|
||||
end
|
||||
|
||||
it "auto-creates an account detail record when a member is created" do
|
||||
@member.account_detail.should be_an_instance_of AccountDetail
|
||||
@member.account.should be_an_instance_of Account
|
||||
end
|
||||
|
||||
it "won't let you create two account details for the same member" do
|
||||
@details = AccountDetail.new(:member_id => @member.id)
|
||||
@details = Account.new(:member_id => @member.id)
|
||||
@details.should_not be_valid
|
||||
end
|
||||
end
|
||||
@@ -29,9 +29,9 @@ describe 'member' do
|
||||
@member.gardens.count.should == 1
|
||||
end
|
||||
|
||||
it 'should have a account detail entry' do
|
||||
it 'should have a accounts entry' do
|
||||
@member.save
|
||||
@member.account_detail.should be_an_instance_of AccountDetail
|
||||
@member.account.should be_an_instance_of Account
|
||||
end
|
||||
|
||||
it "doesn't show email by default" do
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe AccountDetailsController do
|
||||
describe "routing" do
|
||||
|
||||
it "routes to #index" do
|
||||
get("/account_details").should route_to("account_details#index")
|
||||
end
|
||||
|
||||
it "routes to #new" do
|
||||
get("/account_details/new").should route_to("account_details#new")
|
||||
end
|
||||
|
||||
it "routes to #show" do
|
||||
get("/account_details/1").should route_to("account_details#show", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #edit" do
|
||||
get("/account_details/1/edit").should route_to("account_details#edit", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #create" do
|
||||
post("/account_details").should route_to("account_details#create")
|
||||
end
|
||||
|
||||
it "routes to #update" do
|
||||
put("/account_details/1").should route_to("account_details#update", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #destroy" do
|
||||
delete("/account_details/1").should route_to("account_details#destroy", :id => "1")
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
@@ -1,18 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "account_details/edit" do
|
||||
before(:each) do
|
||||
@member = FactoryGirl.create(:member)
|
||||
@account_detail = assign(:account_detail, @member.account_detail)
|
||||
end
|
||||
|
||||
it "renders the edit account_detail form" do
|
||||
render
|
||||
|
||||
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
||||
assert_select "form", :action => account_details_path(@account_detail), :method => "post" do
|
||||
assert_select "input#account_detail_member_id", :name => "account_detail[member_id]"
|
||||
assert_select "input#account_detail_account_type", :name => "account_detail[account_type]"
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,15 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "account_details/index" do
|
||||
before(:each) do
|
||||
@member = FactoryGirl.create(:member)
|
||||
@account_detail = @member.account_detail
|
||||
assign(:account_details, [@account_detail, @account_detail])
|
||||
end
|
||||
|
||||
it "renders a list of account_details" do
|
||||
render
|
||||
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
||||
assert_select "tr>td", :text => @account_detail.member_id.to_s, :count => 2
|
||||
end
|
||||
end
|
||||
@@ -1,18 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "account_details/new" do
|
||||
before(:each) do
|
||||
@member = FactoryGirl.create(:member)
|
||||
assign(:account_detail, @member.account_detail)
|
||||
end
|
||||
|
||||
it "renders new account_detail form" do
|
||||
render
|
||||
|
||||
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
||||
assert_select "form", :action => account_details_path, :method => "post" do
|
||||
assert_select "input#account_detail_member_id", :name => "account_detail[member_id]"
|
||||
assert_select "input#account_detail_account_type", :name => "account_detail[account_type]"
|
||||
end
|
||||
end
|
||||
end
|
||||
18
spec/views/accounts/edit.html.haml_spec.rb
Normal file
18
spec/views/accounts/edit.html.haml_spec.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "accounts/edit" do
|
||||
before(:each) do
|
||||
@member = FactoryGirl.create(:member)
|
||||
@account = assign(:account, @member.account)
|
||||
end
|
||||
|
||||
it "renders the edit account form" do
|
||||
render
|
||||
|
||||
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
||||
assert_select "form", :action => accounts_path(@account), :method => "post" do
|
||||
assert_select "input#account_member_id", :name => "account[member_id]"
|
||||
assert_select "input#account_account_type", :name => "account[account_type]"
|
||||
end
|
||||
end
|
||||
end
|
||||
15
spec/views/accounts/index.html.haml_spec.rb
Normal file
15
spec/views/accounts/index.html.haml_spec.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "accounts/index" do
|
||||
before(:each) do
|
||||
@member = FactoryGirl.create(:member)
|
||||
@account = @member.account
|
||||
assign(:accounts, [@account, @account])
|
||||
end
|
||||
|
||||
it "renders a list of accounts" do
|
||||
render
|
||||
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
||||
assert_select "tr>td", :text => @account.member_id.to_s, :count => 2
|
||||
end
|
||||
end
|
||||
18
spec/views/accounts/new.html.haml_spec.rb
Normal file
18
spec/views/accounts/new.html.haml_spec.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "accounts/new" do
|
||||
before(:each) do
|
||||
@member = FactoryGirl.create(:member)
|
||||
assign(:account, @member.account)
|
||||
end
|
||||
|
||||
it "renders new account form" do
|
||||
render
|
||||
|
||||
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
||||
assert_select "form", :action => accounts_path, :method => "post" do
|
||||
assert_select "input#account_member_id", :name => "account[member_id]"
|
||||
assert_select "input#account_account_type", :name => "account[account_type]"
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,16 +1,16 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "account_details/show" do
|
||||
describe "accounts/show" do
|
||||
before(:each) do
|
||||
@member = FactoryGirl.create(:member)
|
||||
@account_detail = assign(:account_detail, @member.account_detail)
|
||||
@account = assign(:account, @member.account)
|
||||
end
|
||||
|
||||
it "renders attributes in <p>" do
|
||||
render
|
||||
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
||||
rendered.should contain @account_detail.member_id.to_s
|
||||
rendered.should contain @account.member_id.to_s
|
||||
rendered.should contain 'Free account'
|
||||
rendered.should contain @account_detail.paid_until.to_s
|
||||
rendered.should contain @account.paid_until.to_s
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user