disclaimer 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +60 -0
- data/Rakefile +40 -0
- data/app/assets/javascripts/disclaimer/application.js +16 -0
- data/app/assets/javascripts/disclaimer/documents.js +2 -0
- data/app/assets/javascripts/disclaimer/segments.js +2 -0
- data/app/assets/stylesheets/disclaimer/application.css +13 -0
- data/app/assets/stylesheets/disclaimer/documents.css +9 -0
- data/app/assets/stylesheets/disclaimer/segments.css +4 -0
- data/app/controllers/disclaimer/application_controller.rb +4 -0
- data/app/controllers/disclaimer/documents_controller.rb +74 -0
- data/app/controllers/disclaimer/segments_controller.rb +45 -0
- data/app/helpers/disclaimer/application_helper.rb +4 -0
- data/app/helpers/disclaimer/documents_helper.rb +4 -0
- data/app/helpers/disclaimer/segments_helper.rb +4 -0
- data/app/models/disclaimer/document.rb +57 -0
- data/app/models/disclaimer/segment.rb +26 -0
- data/app/models/disclaimer/segment_holder.rb +17 -0
- data/app/views/disclaimer/documents/delete.html.erb +8 -0
- data/app/views/disclaimer/documents/index.html.erb +28 -0
- data/app/views/disclaimer/documents/new.html.erb +48 -0
- data/app/views/disclaimer/documents/show.html.erb +19 -0
- data/app/views/disclaimer/segments/_segment.html.erb +8 -0
- data/app/views/disclaimer/segments/delete.html.erb +8 -0
- data/app/views/disclaimer/segments/index.html.erb +26 -0
- data/app/views/disclaimer/segments/new.html.erb +24 -0
- data/app/views/disclaimer/segments/show.html.erb +2 -0
- data/app/views/layouts/disclaimer/application.html.erb +15 -0
- data/config/routes.rb +18 -0
- data/db/migrate/20121023125748_create_disclaimer_documents.rb +12 -0
- data/db/migrate/20121024074240_create_segments.rb +10 -0
- data/db/migrate/20121024080818_create_disclaimer_segment_holders.rb +11 -0
- data/lib/disclaimer/engine.rb +5 -0
- data/lib/disclaimer/version.rb +3 -0
- data/lib/disclaimer.rb +6 -0
- data/lib/rails/actionpack/lib/action_controller/base.rb +28 -0
- data/lib/tasks/disclaimer_tasks.rake +4 -0
- data/test/disclaimer_test.rb +7 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/javascripts/sample.js +2 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/assets/stylesheets/sample.css +4 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/controllers/sample_controller.rb +12 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/helpers/sample_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/sample/index.html.erb +4 -0
- data/test/dummy/config/application.rb +59 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +10 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/schema.rb +41 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +13228 -0
- data/test/dummy/log/test.log +35207 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/test/functional/sample_controller_test.rb +29 -0
- data/test/dummy/test/unit/helpers/sample_helper_test.rb +4 -0
- data/test/dummy/tmp/cache/assets/B9D/BB0/sprockets%2Fc3340956015865527b738281d0798842 +0 -0
- data/test/dummy/tmp/cache/assets/C5A/090/sprockets%2F163158930fc7f594992ed570eb262440 +0 -0
- data/test/dummy/tmp/cache/assets/C65/6C0/sprockets%2F6411c0191302133114dd7b9452abec58 +0 -0
- data/test/dummy/tmp/cache/assets/C83/2C0/sprockets%2F99d131cd7946c82b8a39070e6b434530 +0 -0
- data/test/dummy/tmp/cache/assets/CD4/F20/sprockets%2F9705276958dc30aad02ae1f4618a60a4 +0 -0
- data/test/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/CE3/0F0/sprockets%2F1c1d13e6a59e0476d7663354de087ff0 +0 -0
- data/test/dummy/tmp/cache/assets/D05/D80/sprockets%2F0f27d3a1d395bf559a2d725033de721c +0 -0
- data/test/dummy/tmp/cache/assets/D14/8E0/sprockets%2F1d0962a03dd3d782c8eadf712769a972 +0 -0
- data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/cache/assets/D51/800/sprockets%2F0b6c1b1792d877f8e8fb3d82d577ca92 +0 -0
- data/test/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/D69/ED0/sprockets%2F5e34b8807c9168eb298bc1eb4d01bc1b +0 -0
- data/test/dummy/tmp/cache/assets/D6A/080/sprockets%2Fb083da81ad739ec14c03d78b63c22d9f +0 -0
- data/test/dummy/tmp/cache/assets/D73/200/sprockets%2Ff550d44b0e67ff62964de563da84c2ab +0 -0
- data/test/dummy/tmp/cache/assets/D9D/D20/sprockets%2F17bfe7df9a25cca0b3e5604f442be847 +0 -0
- data/test/dummy/tmp/cache/assets/DA6/F40/sprockets%2F55aedaf8fe75d461c2c82239e7e1d0b9 +0 -0
- data/test/dummy/tmp/cache/assets/DB4/B10/sprockets%2F1419cefd434468f9dfea571aa7ee59f7 +0 -0
- data/test/dummy/tmp/cache/assets/DC6/910/sprockets%2Faad8dad748c771644d1bbbcf02409fe2 +0 -0
- data/test/dummy/tmp/cache/assets/DCD/6D0/sprockets%2Fe8e47b38d458acad468a0b2bdcd12e76 +0 -0
- data/test/dummy/tmp/cache/assets/DD1/600/sprockets%2Fd61c971a175fe64d20ceefe3e7f4e2b3 +0 -0
- data/test/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/DDD/C60/sprockets%2F59ec92d2bcdf9ece368f07a4ca6509c7 +0 -0
- data/test/dummy/tmp/cache/assets/DE1/2B0/sprockets%2Fdca152daab7ddab59235356c1d2b21db +0 -0
- data/test/dummy/tmp/cache/assets/DFB/DF0/sprockets%2Fa1fb1cc09fd766dcc9e2b9d4a9421db4 +0 -0
- data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/E22/0C0/sprockets%2F72c5c1adba8375dda425a7bfb5ba7c4f +0 -0
- data/test/dummy/tmp/cache/assets/E27/370/sprockets%2Ff374d3bfba2ca636ce768ab8eecb31b3 +0 -0
- data/test/dummy/tmp/cache/assets/E2C/8D0/sprockets%2F234ff42c359a2beddfb9d10ee75aef3d +0 -0
- data/test/dummy/tmp/pids/server.pid +1 -0
- data/test/fixtures/disclaimer/documents.yml +9 -0
- data/test/fixtures/disclaimer/segment_holders.yml +9 -0
- data/test/fixtures/disclaimer/segments.yml +13 -0
- data/test/functional/disclaimer/documents_controller_test.rb +129 -0
- data/test/functional/disclaimer/segments_controller_test.rb +77 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/test_helper.rb +35 -0
- data/test/unit/disclaimer/document_test.rb +36 -0
- data/test/unit/disclaimer/segment_holder_test.rb +9 -0
- data/test/unit/disclaimer/segment_test.rb +59 -0
- data/test/unit/helpers/disclaimer/documents_helper_test.rb +6 -0
- data/test/unit/helpers/disclaimer/segments_helper_test.rb +6 -0
- metadata +330 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/404.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
23
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/422.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/500.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
23
|
+
</div>
|
24
|
+
</body>
|
25
|
+
</html>
|
File without changes
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class SampleControllerTest < ActionController::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@document = Disclaimer::Document.first
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_index_default_redirect
|
10
|
+
get :index
|
11
|
+
assert_redirected_to("/disclaimer/documents/#{@document.name}")
|
12
|
+
assert_equal({@document.name.to_sym => "http://#{request.host}/sample"}, session[:disclaimer])
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_index_with_disclaimer_accepted
|
16
|
+
get(
|
17
|
+
:index,
|
18
|
+
{},
|
19
|
+
:disclaimer => {@document.name.to_sym => :accepted}
|
20
|
+
)
|
21
|
+
assert_response :success
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_bypass_disclaimer
|
25
|
+
get :bypass_disclaimer
|
26
|
+
assert_response :success
|
27
|
+
assert_nil session[:disclaimer], "Session should not be set when disclaimer is bypassed"
|
28
|
+
end
|
29
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
8925
|
@@ -0,0 +1,129 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Disclaimer
|
4
|
+
class DocumentsControllerTest < ActionController::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@document = Document.find(1)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_index
|
11
|
+
get :index
|
12
|
+
assert_response :success
|
13
|
+
assert_equal(Document.all, assigns('documents'))
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_show
|
17
|
+
get :show, :id => @document.name
|
18
|
+
assert_response :success
|
19
|
+
assert_equal(@document, assigns('document'))
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_new
|
23
|
+
get :new
|
24
|
+
assert_response :success
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_create
|
28
|
+
title = "Create document"
|
29
|
+
assert_difference 'Document.count', 1 do
|
30
|
+
post(
|
31
|
+
:create,
|
32
|
+
:document => {
|
33
|
+
:title => title,
|
34
|
+
:name => 'new document'
|
35
|
+
}
|
36
|
+
)
|
37
|
+
end
|
38
|
+
assert_response :redirect
|
39
|
+
assert_equal(title, Document.last.title)
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_edit
|
43
|
+
get :edit, :id => @document.name
|
44
|
+
assert_equal(@document, assigns('document'))
|
45
|
+
assert_response :success
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_update
|
49
|
+
title = "Document update"
|
50
|
+
assert_no_difference 'Document.count' do
|
51
|
+
post(
|
52
|
+
:update,
|
53
|
+
:id => @document.name,
|
54
|
+
:document => {
|
55
|
+
:title => title
|
56
|
+
}
|
57
|
+
)
|
58
|
+
end
|
59
|
+
assert_response :redirect
|
60
|
+
assert_equal(title, @document.reload.title)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_update_with_no_segments
|
64
|
+
assert_equal(2, @document.segments.length)
|
65
|
+
post(
|
66
|
+
:update,
|
67
|
+
:id => @document.name,
|
68
|
+
:document => {
|
69
|
+
:segments => nil
|
70
|
+
}
|
71
|
+
)
|
72
|
+
assert_equal(0, @document.reload.segments.length)
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_adding_one_segment
|
76
|
+
segment = Segment.last
|
77
|
+
post(
|
78
|
+
:update,
|
79
|
+
:id => @document.name,
|
80
|
+
:document => {
|
81
|
+
:segments => {
|
82
|
+
segment.id => 'yes'
|
83
|
+
}
|
84
|
+
}
|
85
|
+
)
|
86
|
+
assert_equal([segment], @document.reload.segments)
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_adding_two_segments
|
90
|
+
test_update_with_no_segments
|
91
|
+
post(
|
92
|
+
:update,
|
93
|
+
:id => @document.name,
|
94
|
+
:document => {
|
95
|
+
:segments => {
|
96
|
+
Segment.first.id => 'yes',
|
97
|
+
Segment.last.id => 'yes'
|
98
|
+
}
|
99
|
+
}
|
100
|
+
)
|
101
|
+
assert_equal(2, @document.reload.segments.length)
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_adding_one_segment_after_two_segments_removed_the_extra_segment
|
105
|
+
test_adding_two_segments
|
106
|
+
test_adding_one_segment
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_delete
|
110
|
+
get :delete, :id => @document.name
|
111
|
+
assert_response :success
|
112
|
+
assert_equal(@document, assigns('document'))
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_destroy
|
116
|
+
assert_difference 'Document.count', -1 do
|
117
|
+
delete :destroy, :id => @document.name, :use_route => :disclaimer
|
118
|
+
end
|
119
|
+
assert_response :redirect
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_accept
|
123
|
+
post :accept, :id => @document.name
|
124
|
+
assert_response :redirect
|
125
|
+
assert_equal({@document.name.to_sym => ACCEPTED}, session[:disclaimer])
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
129
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Disclaimer
|
4
|
+
class SegmentsControllerTest < ActionController::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@segment = Segment.find(1)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_index
|
11
|
+
get :index
|
12
|
+
assert_response :success
|
13
|
+
assert_equal(Segment.all, assigns('segments'))
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_show
|
17
|
+
get :show, :id => @segment.name
|
18
|
+
assert_response :success
|
19
|
+
assert_equal(@segment, assigns('segment'))
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_new
|
23
|
+
get :new
|
24
|
+
assert_response :success
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_create
|
28
|
+
title = "Create segment"
|
29
|
+
assert_difference 'Segment.count', 1 do
|
30
|
+
post(
|
31
|
+
:create,
|
32
|
+
:segment => {
|
33
|
+
:title => title,
|
34
|
+
:name => 'new segment'
|
35
|
+
}
|
36
|
+
)
|
37
|
+
end
|
38
|
+
assert_response :redirect
|
39
|
+
assert_equal(title, Segment.last.title)
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_edit
|
43
|
+
get :edit, :id => @segment.name
|
44
|
+
assert_equal(@segment, assigns('segment'))
|
45
|
+
assert_response :success
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_update
|
49
|
+
title = "Segment update"
|
50
|
+
assert_no_difference 'Segment.count' do
|
51
|
+
post(
|
52
|
+
:update,
|
53
|
+
:id => @segment.name,
|
54
|
+
:segment => {
|
55
|
+
:title => title
|
56
|
+
}
|
57
|
+
)
|
58
|
+
end
|
59
|
+
assert_response :redirect
|
60
|
+
assert_equal(title, @segment.reload.title)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_delete
|
64
|
+
get :delete, :id => @segment.name
|
65
|
+
assert_response :success
|
66
|
+
assert_equal(@segment, assigns('segment'))
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_destroy
|
70
|
+
assert_difference 'Segment.count', -1 do
|
71
|
+
delete :destroy, :id => @segment.name, :use_route => :disclaimer
|
72
|
+
end
|
73
|
+
assert_response :redirect
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Configure Rails Environment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
|
+
require "rails/test_help"
|
6
|
+
|
7
|
+
Rails.backtrace_cleaner.remove_silencers!
|
8
|
+
|
9
|
+
require 'minitest/reporters'
|
10
|
+
MiniTest::Reporters.use!
|
11
|
+
|
12
|
+
# Load support files
|
13
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
14
|
+
|
15
|
+
# Load fixtures from the engine
|
16
|
+
if ActiveSupport::TestCase.method_defined?(:fixture_path=)
|
17
|
+
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
|
18
|
+
end
|
19
|
+
|
20
|
+
class ActiveSupport::TestCase
|
21
|
+
fixtures :all
|
22
|
+
end
|
23
|
+
|
24
|
+
class ActionController::TestCase
|
25
|
+
|
26
|
+
#Overrides get, post etc. to use a default :use_route of :disclaimer
|
27
|
+
def process(action, parameters, session = nil, flash = nil, http_method = 'GET')
|
28
|
+
parameters ||= Hash.new
|
29
|
+
parameters[:use_route] = :disclaimer unless parameters[:use_route]
|
30
|
+
super
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Disclaimer
|
4
|
+
class DocumentTest < ActiveSupport::TestCase
|
5
|
+
def setup
|
6
|
+
@document = Document.find(1)
|
7
|
+
@segment = Segment.find(1)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_setup
|
11
|
+
assert_equal(1, @document.id)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_segment_holder_for
|
15
|
+
segment_holder = @segment.segment_holders.first
|
16
|
+
assert_equal(segment_holder, @document.segment_holder_for(@segment))
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_name_under_scored_on_save
|
20
|
+
@document.update_attribute(:name, "This is a Name")
|
21
|
+
assert_equal('this_is_a_name', @document.name)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_title_if_empty
|
25
|
+
@document.title = ""
|
26
|
+
@document.name = "this_is_a_name"
|
27
|
+
assert_equal("This is a name", @document.title)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_title_if_nil
|
31
|
+
@document.title = nil
|
32
|
+
@document.name = "this_is_a_name"
|
33
|
+
assert_equal("This is a name", @document.title)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Disclaimer
|
4
|
+
class SegmentTest < ActiveSupport::TestCase
|
5
|
+
def setup
|
6
|
+
@document = Document.find(1)
|
7
|
+
@segment = Segment.find(1)
|
8
|
+
@segment_two = Segment.find(2)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_ordering_preserver_via_through
|
12
|
+
assert_equal([@segment.segment_holders.first, @segment_two.segment_holders.first], @document.segment_holders)
|
13
|
+
assert_equal([@segment, @segment_two], @document.segments)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_reordering_via_segment_holder
|
17
|
+
@document.segment_holders.first.move_to_bottom
|
18
|
+
assert_equal([@segment_two, @segment], @document.segments)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_reordering_via_document
|
22
|
+
@document.move_to_bottom(@segment)
|
23
|
+
assert_equal([@segment_two, @segment], @document.segments)
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_reordering_via_document_when_segment_not_in_document
|
27
|
+
assert_raise RuntimeError do
|
28
|
+
@document.move_to_bottom(new_segment)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_cannot_add_duplicate_segments_to_document
|
33
|
+
assert_no_difference '@document.segments.length' do
|
34
|
+
@document.segments << @segment
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_name_under_scored_on_save
|
39
|
+
@segment.update_attribute(:name, "This is a Name")
|
40
|
+
assert_equal('this_is_a_name', @segment.name)
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_title_if_empty
|
44
|
+
@segment.title = ""
|
45
|
+
@segment.name = "this_is_a_name"
|
46
|
+
assert_equal("This is a name", @segment.title)
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_title_if_nil
|
50
|
+
@segment.title = nil
|
51
|
+
@segment.name = "this_is_a_name"
|
52
|
+
assert_equal("This is a name", @segment.title)
|
53
|
+
end
|
54
|
+
|
55
|
+
def new_segment
|
56
|
+
Segment.new(:name => 'not in document')
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|