acts_as_citable 3.0.0.pre.alpha → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/acts_as_citable/base.rb +16 -13
- data/lib/acts_as_citable/version.rb +1 -1
- data/test/acts_as_citable_test.rb +1 -75
- data/test/dummy/README.rdoc +15 -248
- data/test/dummy/Rakefile +1 -2
- data/test/dummy/app/assets/javascripts/application.js +3 -5
- data/test/dummy/app/assets/stylesheets/application.css +5 -3
- data/test/dummy/app/controllers/application_controller.rb +3 -1
- data/test/dummy/app/controllers/test_controller.rb +1 -1
- data/test/dummy/app/models/inherited_record.rb +2 -2
- data/test/dummy/app/models/record.rb +1 -1
- data/test/dummy/app/models/record_changed_field.rb +1 -1
- data/test/dummy/app/views/layouts/application.html.erb +2 -2
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config.ru +1 -1
- data/test/dummy/config/application.rb +1 -37
- data/test/dummy/config/boot.rb +4 -9
- data/test/dummy/config/database.yml +6 -3
- data/test/dummy/config/environment.rb +3 -3
- data/test/dummy/config/environments/development.rb +19 -19
- data/test/dummy/config/environments/production.rb +41 -30
- data/test/dummy/config/environments/test.rb +17 -15
- data/test/dummy/config/initializers/assets.rb +8 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +6 -5
- data/test/dummy/config/initializers/mime_types.rb +0 -1
- data/test/dummy/config/initializers/session_store.rb +1 -6
- data/test/dummy/config/initializers/wrap_parameters.rb +6 -6
- data/test/dummy/config/locales/en.yml +20 -2
- data/test/dummy/config/routes.rb +2 -58
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20130221210429_create_records.rb +3 -3
- data/test/dummy/db/schema.rb +8 -8
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +30 -3148
- data/test/dummy/log/test.log +755 -10228
- data/test/dummy/public/404.html +54 -13
- data/test/dummy/public/422.html +54 -13
- data/test/dummy/public/500.html +53 -12
- data/test/dummy/test/functional/test_controller_test.rb +4 -2
- data/test/dummy/test/unit/inherited_record_test.rb +83 -0
- data/test/dummy/test/unit/record_changed_field_test.rb +69 -3
- data/test/dummy/test/unit/record_test.rb +63 -0
- metadata +27 -15
- data/test/dummy/app/assets/javascripts/test.js +0 -2
- data/test/dummy/app/assets/stylesheets/test.css +0 -4
- data/test/dummy/app/helpers/test_helper.rb +0 -2
- data/test/dummy/config/initializers/secret_token.rb +0 -7
- data/test/dummy/script/rails +0 -6
data/test/dummy/public/404.html
CHANGED
@@ -2,25 +2,66 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
-
<
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
16
54
|
</style>
|
17
55
|
</head>
|
18
56
|
|
19
57
|
<body>
|
20
58
|
<!-- This file lives in public/404.html -->
|
21
59
|
<div class="dialog">
|
22
|
-
<
|
23
|
-
|
60
|
+
<div>
|
61
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
62
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
24
65
|
</div>
|
25
66
|
</body>
|
26
67
|
</html>
|
data/test/dummy/public/422.html
CHANGED
@@ -2,25 +2,66 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<title>The change you wanted was rejected (422)</title>
|
5
|
-
<
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
16
54
|
</style>
|
17
55
|
</head>
|
18
56
|
|
19
57
|
<body>
|
20
58
|
<!-- This file lives in public/422.html -->
|
21
59
|
<div class="dialog">
|
22
|
-
<
|
23
|
-
|
60
|
+
<div>
|
61
|
+
<h1>The change you wanted was rejected.</h1>
|
62
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
24
65
|
</div>
|
25
66
|
</body>
|
26
67
|
</html>
|
data/test/dummy/public/500.html
CHANGED
@@ -2,24 +2,65 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<title>We're sorry, but something went wrong (500)</title>
|
5
|
-
<
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
16
54
|
</style>
|
17
55
|
</head>
|
18
56
|
|
19
57
|
<body>
|
20
58
|
<!-- This file lives in public/500.html -->
|
21
59
|
<div class="dialog">
|
22
|
-
<
|
60
|
+
<div>
|
61
|
+
<h1>We're sorry, but something went wrong.</h1>
|
62
|
+
</div>
|
63
|
+
<p>If you are the application owner check the logs for more information.</p>
|
23
64
|
</div>
|
24
65
|
</body>
|
25
66
|
</html>
|
@@ -14,7 +14,9 @@ class TestControllerTest < ActionController::TestCase
|
|
14
14
|
assert_response :success
|
15
15
|
end
|
16
16
|
test "should not respond to arbitrary format" do
|
17
|
-
|
18
|
-
|
17
|
+
assert_raise ActionController::UnknownFormat do
|
18
|
+
get :test, :format => "bugaboo", :use_route => :test
|
19
|
+
assert_response :not_acceptable
|
20
|
+
end
|
19
21
|
end
|
20
22
|
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class InheritedRecordTest < ActiveSupport::TestCase
|
4
|
+
test "should be able to create a new Inherited Record" do
|
5
|
+
rec = InheritedRecord.new(:data => "itemType: book", :format => "csf")
|
6
|
+
assert_equal "TY - BOOK\nER -\n\n", rec.to_ris
|
7
|
+
assert_equal "@book{????\n}", rec.to_bibtex
|
8
|
+
assert_equal "rft.ulr_ver=Z39.88-2004&rft.ctx_ver=Z39.88-2004&rft.rfr_id=info:sid/libraries.nyu.edu:citero&rft_val_fmlt=info:ofi/fmt:kev:mtx:book&rft.genre=book", rec.to_openurl
|
9
|
+
assert_equal "{\"source\":\"book\",\"book\":{\"title\":null},\"pubtype\":{\"main\":\"pubnonperiodical\"},\"pubnonperiodical\":{},\"contributors\":[]}", rec.to_easybib
|
10
|
+
end
|
11
|
+
|
12
|
+
test "should check if i can use the Inherited record" do
|
13
|
+
assert rec = InheritedRecord.new( :data => "data", :format => "from_format")
|
14
|
+
assert rec.destroy
|
15
|
+
end
|
16
|
+
|
17
|
+
test "should check to see if format fields are set" do
|
18
|
+
assert 'format', InheritedRecord.format_field
|
19
|
+
end
|
20
|
+
|
21
|
+
test "should check to see if Inherited records can be converted" do
|
22
|
+
rec = InheritedRecord.new(:data => "itemType: book", :format => "csf")
|
23
|
+
assert rec.respond_to?(:to_ris)
|
24
|
+
assert rec.respond_to?(:to_bibtex)
|
25
|
+
assert rec.respond_to?(:to_openurl)
|
26
|
+
assert rec.respond_to?(:to_csf)
|
27
|
+
assert rec.respond_to?(:to_easybib)
|
28
|
+
assert rec.respond_to?(:to_refworks_tagged)
|
29
|
+
assert rec.respond_to?(:csf)
|
30
|
+
assert rec.destroy
|
31
|
+
end
|
32
|
+
|
33
|
+
# test "should work with models inherited acts_as_citable models" do
|
34
|
+
# rec = InheritedRecord.new(:data => "itemType: book", :format => "csf")
|
35
|
+
# assert_equal "TY - BOOK\nER -\n\n", rec.to_ris
|
36
|
+
# assert_equal "@book{????\n}", rec.to_bibtex
|
37
|
+
# assert_equal "rft.ulr_ver=Z39.88-2004&rft.ctx_ver=Z39.88-2004&rft.rfr_id=info:sid/libraries.nyu.edu:citero&rft_val_fmlt=info:ofi/fmt:kev:mtx:book&rft.genre=book", rec.to_openurl
|
38
|
+
# assert_equal "{\"source\":\"book\",\"book\":{\"title\":null},\"pubtype\":{\"main\":\"pubnonperiodical\"},\"pubnonperiodical\":{},\"contributors\":[]}", rec.to_easybib
|
39
|
+
# assert rec.destroy
|
40
|
+
# end
|
41
|
+
|
42
|
+
test "should check to see if you cannot convert from" do
|
43
|
+
rec = InheritedRecord.new(:data => "itemType: book", :format => "csf")
|
44
|
+
assert !rec.respond_to?(:from_ris)
|
45
|
+
assert !rec.respond_to?(:from_bibtex)
|
46
|
+
assert !rec.respond_to?(:from_openurl)
|
47
|
+
assert !rec.respond_to?(:from_csf)
|
48
|
+
assert !rec.respond_to?(:from_pnx)
|
49
|
+
end
|
50
|
+
|
51
|
+
test "should raise no method error" do
|
52
|
+
rec = Record.new(:data => "itemType: book", :format => "csf")
|
53
|
+
assert_raise NoMethodError do
|
54
|
+
rec.from_ris
|
55
|
+
end
|
56
|
+
assert rec.destroy
|
57
|
+
end
|
58
|
+
|
59
|
+
test "should be available to convert to" do
|
60
|
+
rec = InheritedRecord.new(:data => "itemType: book", :format => "csf")
|
61
|
+
assert_equal "TY - BOOK\nER -\n\n", rec.to_ris
|
62
|
+
assert_equal "@book{????\n}", rec.to_bibtex
|
63
|
+
assert_equal "rft.ulr_ver=Z39.88-2004&rft.ctx_ver=Z39.88-2004&rft.rfr_id=info:sid/libraries.nyu.edu:citero&rft_val_fmlt=info:ofi/fmt:kev:mtx:book&rft.genre=book", rec.to_openurl
|
64
|
+
assert_equal "{\"source\":\"book\",\"book\":{\"title\":null},\"pubtype\":{\"main\":\"pubnonperiodical\"},\"pubnonperiodical\":{},\"contributors\":[]}", rec.to_easybib
|
65
|
+
assert rec.destroy
|
66
|
+
end
|
67
|
+
|
68
|
+
test "arrays should be able to convert to ris and bibtex" do
|
69
|
+
arr = Array.new
|
70
|
+
arr << InheritedRecord.new(:data => "itemType: book", :format => "csf") << InheritedRecord.create(:data => "itemType: book", :format => "csf")
|
71
|
+
assert arr.to_bibtex
|
72
|
+
assert arr.to_ris
|
73
|
+
arr.each {|rec| assert rec.destroy}
|
74
|
+
end
|
75
|
+
|
76
|
+
test "should be able to convert to an export STYLE" do
|
77
|
+
rec = InheritedRecord.new(:data => "itemType: book", :format => "csf")
|
78
|
+
assert_equal "<div class=\"csl-bib-body\">\n <div class=\"csl-entry\"> (n.d.).</div>\n</div>", rec.to_apa
|
79
|
+
assert_equal "<div class=\"csl-bib-body\">\n <div class=\"csl-entry\"> Print.</div>\n</div>", rec.to_mla
|
80
|
+
assert_equal "<div class=\"csl-bib-body\">\n\n[CSL STYLE ERROR: reference with no printed form.]\n</div>", rec.to_chicago_author_date
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
@@ -1,7 +1,73 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class RecordChangedFieldTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
test "should be able to create a new Record with changed fields" do
|
5
|
+
rec = RecordChangedField.new(:data => "itemType: book", :from_format => "csf")
|
6
|
+
assert_equal "TY - BOOK\nER -\n\n", rec.to_ris
|
7
|
+
assert_equal "@book{????\n}", rec.to_bibtex
|
8
|
+
assert_equal "rft.ulr_ver=Z39.88-2004&rft.ctx_ver=Z39.88-2004&rft.rfr_id=info:sid/libraries.nyu.edu:citero&rft_val_fmlt=info:ofi/fmt:kev:mtx:book&rft.genre=book", rec.to_openurl
|
9
|
+
assert_equal "{\"source\":\"book\",\"book\":{\"title\":null},\"pubtype\":{\"main\":\"pubnonperiodical\"},\"pubnonperiodical\":{},\"contributors\":[]}", rec.to_easybib
|
10
|
+
end
|
11
|
+
|
12
|
+
test "should check if i can use the record with changed fields" do
|
13
|
+
assert rec = RecordChangedField.new( :data => "data", :from_format => "from_format")
|
14
|
+
assert rec.destroy
|
15
|
+
end
|
16
|
+
|
17
|
+
test "should check to see if from_format fields are set" do
|
18
|
+
assert 'from_format', RecordChangedField.format_field
|
19
|
+
end
|
20
|
+
|
21
|
+
test "should check to see if records with changed fields can be converted" do
|
22
|
+
rec = RecordChangedField.new(:data => "itemType: book", :from_format => "csf")
|
23
|
+
assert rec.respond_to?(:to_ris)
|
24
|
+
assert rec.respond_to?(:to_bibtex)
|
25
|
+
assert rec.respond_to?(:to_openurl)
|
26
|
+
assert rec.respond_to?(:to_csf)
|
27
|
+
assert rec.respond_to?(:to_easybib)
|
28
|
+
assert rec.respond_to?(:to_refworks_tagged)
|
29
|
+
assert rec.respond_to?(:csf)
|
30
|
+
assert rec.destroy
|
31
|
+
end
|
32
|
+
|
33
|
+
test "should check to see if you cannot convert from" do
|
34
|
+
rec = RecordChangedField.new(:data => "itemType: book", :from_format => "csf")
|
35
|
+
assert !rec.respond_to?(:from_ris)
|
36
|
+
assert !rec.respond_to?(:from_bibtex)
|
37
|
+
assert !rec.respond_to?(:from_openurl)
|
38
|
+
assert !rec.respond_to?(:from_csf)
|
39
|
+
assert !rec.respond_to?(:from_pnx)
|
40
|
+
end
|
41
|
+
|
42
|
+
test "should raise no method error" do
|
43
|
+
rec = RecordChangedField.new(:data => "itemType: book", :from_format => "csf")
|
44
|
+
assert_raise NoMethodError do
|
45
|
+
rec.from_ris
|
46
|
+
end
|
47
|
+
assert rec.destroy
|
48
|
+
end
|
49
|
+
|
50
|
+
test "should be available to convert to" do
|
51
|
+
rec = RecordChangedField.new(:data => "itemType: book", :from_format => "csf")
|
52
|
+
assert_equal "TY - BOOK\nER -\n\n", rec.to_ris
|
53
|
+
assert_equal "@book{????\n}", rec.to_bibtex
|
54
|
+
assert_equal "rft.ulr_ver=Z39.88-2004&rft.ctx_ver=Z39.88-2004&rft.rfr_id=info:sid/libraries.nyu.edu:citero&rft_val_fmlt=info:ofi/fmt:kev:mtx:book&rft.genre=book", rec.to_openurl
|
55
|
+
assert_equal "{\"source\":\"book\",\"book\":{\"title\":null},\"pubtype\":{\"main\":\"pubnonperiodical\"},\"pubnonperiodical\":{},\"contributors\":[]}", rec.to_easybib
|
56
|
+
assert rec.destroy
|
57
|
+
end
|
58
|
+
|
59
|
+
test "arrays should be able to convert to ris and bibtex" do
|
60
|
+
arr = Array.new
|
61
|
+
arr << RecordChangedField.new(:data => "itemType: book", :from_format => "csf") << RecordChangedField.create(:data => "itemType: book", :from_format => "csf")
|
62
|
+
assert arr.to_bibtex
|
63
|
+
assert arr.to_ris
|
64
|
+
arr.each {|rec| assert rec.destroy}
|
65
|
+
end
|
66
|
+
|
67
|
+
test "should be able to convert to an export STYLE" do
|
68
|
+
rec = RecordChangedField.new(:data => "itemType: book", :from_format => "csf")
|
69
|
+
assert_equal "<div class=\"csl-bib-body\">\n <div class=\"csl-entry\"> (n.d.).</div>\n</div>", rec.to_apa
|
70
|
+
assert_equal "<div class=\"csl-bib-body\">\n <div class=\"csl-entry\"> Print.</div>\n</div>", rec.to_mla
|
71
|
+
assert_equal "<div class=\"csl-bib-body\">\n\n[CSL STYLE ERROR: reference with no printed form.]\n</div>", rec.to_chicago_author_date
|
72
|
+
end
|
7
73
|
end
|
@@ -8,4 +8,67 @@ class RecordTest < ActiveSupport::TestCase
|
|
8
8
|
assert_equal "rft.ulr_ver=Z39.88-2004&rft.ctx_ver=Z39.88-2004&rft.rfr_id=info:sid/libraries.nyu.edu:citero&rft_val_fmlt=info:ofi/fmt:kev:mtx:book&rft.genre=book", rec.to_openurl
|
9
9
|
assert_equal "{\"source\":\"book\",\"book\":{\"title\":null},\"pubtype\":{\"main\":\"pubnonperiodical\"},\"pubnonperiodical\":{},\"contributors\":[]}", rec.to_easybib
|
10
10
|
end
|
11
|
+
|
12
|
+
test "should check if i can use the record" do
|
13
|
+
assert rec = Record.new( :data => "data", :format => "from_format")
|
14
|
+
assert rec.destroy
|
15
|
+
end
|
16
|
+
|
17
|
+
test "should check to see if format fields are set" do
|
18
|
+
assert 'format', Record.format_field
|
19
|
+
end
|
20
|
+
|
21
|
+
test "should check to see if records can be converted" do
|
22
|
+
rec = Record.new(:data => "itemType: book", :format => "csf")
|
23
|
+
assert rec.respond_to?(:to_ris)
|
24
|
+
assert rec.respond_to?(:to_bibtex)
|
25
|
+
assert rec.respond_to?(:to_openurl)
|
26
|
+
assert rec.respond_to?(:to_csf)
|
27
|
+
assert rec.respond_to?(:to_easybib)
|
28
|
+
assert rec.respond_to?(:to_refworks_tagged)
|
29
|
+
assert rec.respond_to?(:csf)
|
30
|
+
assert rec.destroy
|
31
|
+
end
|
32
|
+
|
33
|
+
test "should check to see if you cannot convert from" do
|
34
|
+
rec = Record.new(:data => "itemType: book", :format => "csf")
|
35
|
+
assert !rec.respond_to?(:from_ris)
|
36
|
+
assert !rec.respond_to?(:from_bibtex)
|
37
|
+
assert !rec.respond_to?(:from_openurl)
|
38
|
+
assert !rec.respond_to?(:from_csf)
|
39
|
+
assert !rec.respond_to?(:from_pnx)
|
40
|
+
end
|
41
|
+
|
42
|
+
test "should raise no method error" do
|
43
|
+
rec = Record.new(:data => "itemType: book", :format => "csf")
|
44
|
+
assert_raise NoMethodError do
|
45
|
+
rec.from_ris
|
46
|
+
end
|
47
|
+
assert rec.destroy
|
48
|
+
end
|
49
|
+
|
50
|
+
test "should be available to convert to" do
|
51
|
+
rec = Record.new(:data => "itemType: book", :format => "csf")
|
52
|
+
assert_equal "TY - BOOK\nER -\n\n", rec.to_ris
|
53
|
+
assert_equal "@book{????\n}", rec.to_bibtex
|
54
|
+
assert_equal "rft.ulr_ver=Z39.88-2004&rft.ctx_ver=Z39.88-2004&rft.rfr_id=info:sid/libraries.nyu.edu:citero&rft_val_fmlt=info:ofi/fmt:kev:mtx:book&rft.genre=book", rec.to_openurl
|
55
|
+
assert_equal "{\"source\":\"book\",\"book\":{\"title\":null},\"pubtype\":{\"main\":\"pubnonperiodical\"},\"pubnonperiodical\":{},\"contributors\":[]}", rec.to_easybib
|
56
|
+
assert rec.destroy
|
57
|
+
end
|
58
|
+
|
59
|
+
test "arrays should be able to convert to ris and bibtex" do
|
60
|
+
arr = Array.new
|
61
|
+
arr << Record.new(:data => "itemType: book", :format => "csf") << Record.create(:data => "itemType: book", :format => "csf")
|
62
|
+
assert arr.to_bibtex
|
63
|
+
assert arr.to_ris
|
64
|
+
arr.each {|rec| assert rec.destroy}
|
65
|
+
end
|
66
|
+
|
67
|
+
test "should be able to convert to an export STYLE" do
|
68
|
+
rec = Record.new(:data => "itemType: book", :format => "csf")
|
69
|
+
assert_equal "<div class=\"csl-bib-body\">\n <div class=\"csl-entry\"> (n.d.).</div>\n</div>", rec.to_apa
|
70
|
+
assert_equal "<div class=\"csl-bib-body\">\n <div class=\"csl-entry\"> Print.</div>\n</div>", rec.to_mla
|
71
|
+
assert_equal "<div class=\"csl-bib-body\">\n\n[CSL STYLE ERROR: reference with no printed form.]\n</div>", rec.to_chicago_author_date
|
72
|
+
end
|
73
|
+
|
11
74
|
end
|