dorsale 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +31 -0
- data/app/assets/javascripts/dorsale/addresses.js +2 -0
- data/app/assets/javascripts/dorsale/application.js +13 -0
- data/app/assets/stylesheets/dorsale/addresses.css +4 -0
- data/app/assets/stylesheets/dorsale/application.css +13 -0
- data/app/assets/stylesheets/scaffold.css +56 -0
- data/app/controllers/dorsale/addresses_controller.rb +62 -0
- data/app/controllers/dorsale/application_controller.rb +4 -0
- data/app/helpers/dorsale/addresses_helper.rb +4 -0
- data/app/helpers/dorsale/application_helper.rb +4 -0
- data/app/models/dorsale/address.rb +10 -0
- data/app/views/dorsale/addresses/_form.html.slim +24 -0
- data/app/views/dorsale/addresses/edit.html.slim +8 -0
- data/app/views/dorsale/addresses/index.html.slim +29 -0
- data/app/views/dorsale/addresses/new.html.slim +5 -0
- data/app/views/dorsale/addresses/show.html.slim +21 -0
- data/config/routes.rb +4 -0
- data/db/migrate/20141010140200_create_dorsale_addresses.rb +13 -0
- data/db/migrate/20141014072756_add_polymorphic_fields_to_addresses.rb +6 -0
- data/lib/dorsale.rb +4 -0
- data/lib/dorsale/engine.rb +12 -0
- data/lib/dorsale/version.rb +3 -0
- data/lib/tasks/dorsale_tasks.rake +4 -0
- data/spec/controllers/dorsale/addresses_controller_spec.rb +162 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +28 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +32 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/schema.rb +28 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +27 -0
- data/spec/dummy/log/test.log +2937 -0
- data/spec/dummy/public/404.html +58 -0
- data/spec/dummy/public/422.html +58 -0
- data/spec/dummy/public/500.html +57 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/factories/dorsale_addresses.rb +11 -0
- data/spec/helpers/dorsale/addresses_helper_spec.rb +16 -0
- data/spec/models/dorsale/address_spec.rb +36 -0
- data/spec/rails_helper.rb +58 -0
- data/spec/routing/dorsale/addresses_routing_spec.rb +38 -0
- data/spec/spec_helper.rb +86 -0
- data/spec/views/dorsale/addresses/edit.html.slim_spec.rb +32 -0
- data/spec/views/dorsale/addresses/index.html.slim_spec.rb +32 -0
- data/spec/views/dorsale/addresses/new.html.slim_spec.rb +32 -0
- data/spec/views/dorsale/addresses/show.html.slim_spec.rb +24 -0
- metadata +260 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5bea37eaafb20bdaba5793f2c38b89e13fbbf36a
|
4
|
+
data.tar.gz: 993b6a602b566c811889d6f02c58b82a27f9ede4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ef619e2a3ca9d970fa44733993df28f41f6023c9550114c70719652c433b3db196cbc23c5a31837e7fc65e860b1ecfbad853e0969cd625ceb21a9df449809239
|
7
|
+
data.tar.gz: 2fa739ddf42a42c74081066cb849ad82e6cb227c91e3a62160da40bdc7b94624133ae6b3215edb9509b6967c7ac5569825a9699b3f83c74393cb05a6f4488039
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2014 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'Dorsale'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
Bundler::GemHelper.install_tasks
|
23
|
+
|
24
|
+
Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
|
25
|
+
require 'rspec/core'
|
26
|
+
require 'rspec/core/rake_task'
|
27
|
+
|
28
|
+
desc "Run all specs in spec directory (excluding plugin specs)"
|
29
|
+
RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
|
30
|
+
|
31
|
+
task :default => :spec
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
@@ -0,0 +1,56 @@
|
|
1
|
+
body { background-color: #fff; color: #333; }
|
2
|
+
|
3
|
+
body, p, ol, ul, td {
|
4
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
5
|
+
font-size: 13px;
|
6
|
+
line-height: 18px;
|
7
|
+
}
|
8
|
+
|
9
|
+
pre {
|
10
|
+
background-color: #eee;
|
11
|
+
padding: 10px;
|
12
|
+
font-size: 11px;
|
13
|
+
}
|
14
|
+
|
15
|
+
a { color: #000; }
|
16
|
+
a:visited { color: #666; }
|
17
|
+
a:hover { color: #fff; background-color:#000; }
|
18
|
+
|
19
|
+
div.field, div.actions {
|
20
|
+
margin-bottom: 10px;
|
21
|
+
}
|
22
|
+
|
23
|
+
#notice {
|
24
|
+
color: green;
|
25
|
+
}
|
26
|
+
|
27
|
+
.field_with_errors {
|
28
|
+
padding: 2px;
|
29
|
+
background-color: red;
|
30
|
+
display: table;
|
31
|
+
}
|
32
|
+
|
33
|
+
#error_explanation {
|
34
|
+
width: 450px;
|
35
|
+
border: 2px solid red;
|
36
|
+
padding: 7px;
|
37
|
+
padding-bottom: 0;
|
38
|
+
margin-bottom: 20px;
|
39
|
+
background-color: #f0f0f0;
|
40
|
+
}
|
41
|
+
|
42
|
+
#error_explanation h2 {
|
43
|
+
text-align: left;
|
44
|
+
font-weight: bold;
|
45
|
+
padding: 5px 5px 5px 15px;
|
46
|
+
font-size: 12px;
|
47
|
+
margin: -7px;
|
48
|
+
margin-bottom: 0px;
|
49
|
+
background-color: #c00;
|
50
|
+
color: #fff;
|
51
|
+
}
|
52
|
+
|
53
|
+
#error_explanation ul li {
|
54
|
+
font-size: 12px;
|
55
|
+
list-style: square;
|
56
|
+
}
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require_dependency "dorsale/application_controller"
|
2
|
+
|
3
|
+
module Dorsale
|
4
|
+
class AddressesController < ApplicationController
|
5
|
+
before_action :set_address, only: [:show, :edit, :update, :destroy]
|
6
|
+
|
7
|
+
# GET /addresses
|
8
|
+
def index
|
9
|
+
@addresses = Address.all
|
10
|
+
end
|
11
|
+
|
12
|
+
# GET /addresses/1
|
13
|
+
def show
|
14
|
+
end
|
15
|
+
|
16
|
+
# GET /addresses/new
|
17
|
+
def new
|
18
|
+
@address = Address.new
|
19
|
+
end
|
20
|
+
|
21
|
+
# GET /addresses/1/edit
|
22
|
+
def edit
|
23
|
+
end
|
24
|
+
|
25
|
+
# POST /addresses
|
26
|
+
def create
|
27
|
+
@address = Address.new(address_params)
|
28
|
+
|
29
|
+
if @address.save
|
30
|
+
redirect_to @address, notice: 'Address was successfully created.'
|
31
|
+
else
|
32
|
+
render action: 'new'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# PATCH/PUT /addresses/1
|
37
|
+
def update
|
38
|
+
if @address.update(address_params)
|
39
|
+
redirect_to [dorsale, @address], notice: 'Address was successfully updated.'
|
40
|
+
else
|
41
|
+
render action: 'edit'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# DELETE /addresses/1
|
46
|
+
def destroy
|
47
|
+
@address.destroy
|
48
|
+
redirect_to dorsale.addresses_url, notice: 'Address was successfully destroyed.'
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
# Use callbacks to share common setup or constraints between actions.
|
53
|
+
def set_address
|
54
|
+
@address = Address.find(params[:id])
|
55
|
+
end
|
56
|
+
|
57
|
+
# Only allow a trusted parameter "white list" through.
|
58
|
+
def address_params
|
59
|
+
params.require(:address).permit(:street, :street_bis, :city, :zip, :country)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Dorsale
|
2
|
+
class Address < ActiveRecord::Base
|
3
|
+
validates_presence_of :city
|
4
|
+
belongs_to :addressable, polymorphic: true
|
5
|
+
|
6
|
+
def one_line
|
7
|
+
result = [street, street_bis, [zip, city].delete_if {|e| e.blank?}.join(' '), country].delete_if {|e| e.blank?}.join(', ')
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
= form_for [dorsale, @address] do |f|
|
2
|
+
- if @address.errors.any?
|
3
|
+
#error_explanation
|
4
|
+
h2 = "#{pluralize(@address.errors.count, "error")} prohibited this address from being saved:"
|
5
|
+
ul
|
6
|
+
- @address.errors.full_messages.each do |message|
|
7
|
+
li = message
|
8
|
+
|
9
|
+
.field
|
10
|
+
= f.label :street
|
11
|
+
= f.text_field :street
|
12
|
+
.field
|
13
|
+
= f.label :street_bis
|
14
|
+
= f.text_field :street_bis
|
15
|
+
.field
|
16
|
+
= f.label :city
|
17
|
+
= f.text_field :city
|
18
|
+
.field
|
19
|
+
= f.label :zip
|
20
|
+
= f.text_field :zip
|
21
|
+
.field
|
22
|
+
= f.label :country
|
23
|
+
= f.text_field :country
|
24
|
+
.actions = f.submit 'Save'
|
@@ -0,0 +1,29 @@
|
|
1
|
+
h1 Listing addresses
|
2
|
+
|
3
|
+
table
|
4
|
+
thead
|
5
|
+
tr
|
6
|
+
th Street
|
7
|
+
th Street bis
|
8
|
+
th City
|
9
|
+
th Zip
|
10
|
+
th Country
|
11
|
+
th
|
12
|
+
th
|
13
|
+
th
|
14
|
+
|
15
|
+
tbody
|
16
|
+
- @addresses.each do |address|
|
17
|
+
tr
|
18
|
+
td = address.street
|
19
|
+
td = address.street_bis
|
20
|
+
td = address.city
|
21
|
+
td = address.zip
|
22
|
+
td = address.country
|
23
|
+
td = link_to 'Show', [dorsale, address]
|
24
|
+
td = link_to 'Edit', dorsale.edit_address_path(address)
|
25
|
+
td = link_to 'Destroy', [dorsale, address], data: {:confirm => 'Are you sure?'}, :method => :delete
|
26
|
+
|
27
|
+
br
|
28
|
+
|
29
|
+
= link_to 'New Address', dorsale.new_address_path
|
@@ -0,0 +1,21 @@
|
|
1
|
+
p#notice = notice
|
2
|
+
|
3
|
+
p
|
4
|
+
strong Street:
|
5
|
+
= @address.street
|
6
|
+
p
|
7
|
+
strong Street bis:
|
8
|
+
= @address.street_bis
|
9
|
+
p
|
10
|
+
strong City:
|
11
|
+
= @address.city
|
12
|
+
p
|
13
|
+
strong Zip:
|
14
|
+
= @address.zip
|
15
|
+
p
|
16
|
+
strong Country:
|
17
|
+
= @address.country
|
18
|
+
|
19
|
+
= link_to 'Edit', dorsale.edit_address_path(@address)
|
20
|
+
'|
|
21
|
+
= link_to 'Back', dorsale.addresses_path
|
data/config/routes.rb
ADDED
data/lib/dorsale.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
module Dorsale
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
isolate_namespace Dorsale
|
4
|
+
|
5
|
+
config.generators do |g|
|
6
|
+
g.test_framework :rspec, :fixture => false
|
7
|
+
g.fixture_replacement :factory_girl, :dir => 'spec/factories'
|
8
|
+
g.template_engine :slim
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,162 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
4
|
+
# It demonstrates how one might use RSpec to specify the controller code that
|
5
|
+
# was generated by Rails when you ran the scaffold generator.
|
6
|
+
#
|
7
|
+
# It assumes that the implementation code is generated by the rails scaffold
|
8
|
+
# generator. If you are using any extension libraries to generate different
|
9
|
+
# controller code, this generated spec may or may not pass.
|
10
|
+
#
|
11
|
+
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
12
|
+
# of tools you can use to make these specs even more expressive, but we're
|
13
|
+
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
14
|
+
#
|
15
|
+
# Compared to earlier versions of this generator, there is very limited use of
|
16
|
+
# stubs and message expectations in this spec. Stubs are only used when there
|
17
|
+
# is no simpler way to get a handle on the object needed for the example.
|
18
|
+
# Message expectations are only used when there is no simpler way to specify
|
19
|
+
# that an instance is receiving a specific message.
|
20
|
+
|
21
|
+
module Dorsale
|
22
|
+
RSpec.describe AddressesController, :type => :controller do
|
23
|
+
routes { Dorsale::Engine.routes }
|
24
|
+
|
25
|
+
# This should return the minimal set of attributes required to create a valid
|
26
|
+
# Address. As you add validations to Address, be sure to
|
27
|
+
# adjust the attributes here as well.
|
28
|
+
let(:valid_attributes) {
|
29
|
+
FactoryGirl.attributes_for(:dorsale_address)
|
30
|
+
}
|
31
|
+
|
32
|
+
let(:invalid_attributes) {
|
33
|
+
{city: ''}
|
34
|
+
}
|
35
|
+
|
36
|
+
# This should return the minimal set of values that should be in the session
|
37
|
+
# in order to pass any filters (e.g. authentication) defined in
|
38
|
+
# AddressesController. Be sure to keep this updated too.
|
39
|
+
let(:valid_session) { {} }
|
40
|
+
|
41
|
+
describe "GET index" do
|
42
|
+
it "assigns all addresses as @addresses" do
|
43
|
+
address = Address.create! valid_attributes
|
44
|
+
get :index, {}, valid_session
|
45
|
+
expect(assigns(:addresses)).to eq([address])
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "GET show" do
|
50
|
+
it "assigns the requested address as @address" do
|
51
|
+
address = Address.create! valid_attributes
|
52
|
+
get :show, {:id => address.to_param}, valid_session
|
53
|
+
expect(assigns(:address)).to eq(address)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "GET new" do
|
58
|
+
it "assigns a new address as @address" do
|
59
|
+
get :new, {}, valid_session
|
60
|
+
expect(assigns(:address)).to be_a_new(Address)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "GET edit" do
|
65
|
+
it "assigns the requested address as @address" do
|
66
|
+
address = Address.create! valid_attributes
|
67
|
+
get :edit, {:id => address.to_param}, valid_session
|
68
|
+
expect(assigns(:address)).to eq(address)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "POST create" do
|
73
|
+
describe "with valid params" do
|
74
|
+
it "creates a new Address" do
|
75
|
+
expect {
|
76
|
+
post :create, {:address => valid_attributes}, valid_session
|
77
|
+
}.to change(Address, :count).by(1)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "assigns a newly created address as @address" do
|
81
|
+
post :create, {:address => valid_attributes}, valid_session
|
82
|
+
expect(assigns(:address)).to be_a(Address)
|
83
|
+
expect(assigns(:address)).to be_persisted
|
84
|
+
end
|
85
|
+
|
86
|
+
it "redirects to the created address" do
|
87
|
+
post :create, {:address => valid_attributes}, valid_session
|
88
|
+
expect(response).to redirect_to(Address.last)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "with invalid params" do
|
93
|
+
it "assigns a newly created but unsaved address as @address" do
|
94
|
+
post :create, {:address => invalid_attributes}, valid_session
|
95
|
+
expect(assigns(:address)).to be_a_new(Address)
|
96
|
+
end
|
97
|
+
|
98
|
+
it "re-renders the 'new' template" do
|
99
|
+
post :create, {:address => invalid_attributes}, valid_session
|
100
|
+
expect(response).to render_template("new")
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe "PUT update" do
|
106
|
+
describe "with valid params" do
|
107
|
+
let(:new_attributes) {
|
108
|
+
{city: 'new city'}
|
109
|
+
}
|
110
|
+
|
111
|
+
it "updates the requested address" do
|
112
|
+
address = Address.create! valid_attributes
|
113
|
+
put :update, {:id => address.to_param, :address => new_attributes}, valid_session
|
114
|
+
address.reload
|
115
|
+
expect(address.city).to eq('new city')
|
116
|
+
end
|
117
|
+
|
118
|
+
it "assigns the requested address as @address" do
|
119
|
+
address = Address.create! valid_attributes
|
120
|
+
put :update, {:id => address.to_param, :address => valid_attributes}, valid_session
|
121
|
+
expect(assigns(:address)).to eq(address)
|
122
|
+
end
|
123
|
+
|
124
|
+
it "redirects to the address" do
|
125
|
+
address = Address.create! valid_attributes
|
126
|
+
put :update, {:id => address.to_param, :address => valid_attributes}, valid_session
|
127
|
+
expect(response).to redirect_to(address)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
describe "with invalid params" do
|
132
|
+
it "assigns the address as @address" do
|
133
|
+
address = Address.create! valid_attributes
|
134
|
+
put :update, {:id => address.to_param, :address => invalid_attributes}, valid_session
|
135
|
+
expect(assigns(:address)).to eq(address)
|
136
|
+
end
|
137
|
+
|
138
|
+
it "re-renders the 'edit' template" do
|
139
|
+
address = Address.create! valid_attributes
|
140
|
+
put :update, {:id => address.to_param, :address => invalid_attributes}, valid_session
|
141
|
+
expect(response).to render_template("edit")
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
describe "DELETE destroy" do
|
147
|
+
it "destroys the requested address" do
|
148
|
+
address = Address.create! valid_attributes
|
149
|
+
expect {
|
150
|
+
delete :destroy, {:id => address.to_param}, valid_session
|
151
|
+
}.to change(Address, :count).by(-1)
|
152
|
+
end
|
153
|
+
|
154
|
+
it "redirects to the addresses list" do
|
155
|
+
address = Address.create! valid_attributes
|
156
|
+
delete :destroy, {:id => address.to_param}, valid_session
|
157
|
+
expect(response).to redirect_to(addresses_url)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
end
|
162
|
+
end
|