works_cited 0.1.1 → 0.1.5
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 +4 -4
- data/Gemfile +1 -1
- data/README.md +1 -1
- data/VERSION +1 -1
- data/app/controllers/works_cited/citations_controller.rb +40 -44
- data/app/helpers/works_cited/application_helper.rb +1 -0
- data/app/models/works_cited/citation.rb +1 -1
- data/app/models/works_cited/contributor.rb +1 -1
- data/config/initializers/simple_form.rb +7 -3
- data/config/routes.rb +3 -1
- data/lib/works_cited/configuration.rb +1 -3
- data/lib/works_cited/engine.rb +2 -2
- data/lib/works_cited/mixins/has_works_cited.rb +1 -0
- data/lib/works_cited.rb +5 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +12010 -0
- data/spec/factories/users.rb +2 -0
- data/spec/models/works_cited/contributor_spec.rb +0 -2
- data/spec/requests/works_cited/citations_spec.rb +150 -115
- data/spec/routing/works_cited/citations_routing_spec.rb +2 -0
- data/works_cited.gemspec +4 -7
- metadata +12 -15
- data/.travis.yml +0 -3
- data/bin/rails +0 -16
data/spec/factories/users.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
require 'rails_helper'
|
4
4
|
|
5
|
-
# rubocop:disable Metrics/ModuleLength
|
6
5
|
module WorksCited
|
7
6
|
RSpec.describe Contributor, type: :model do
|
8
7
|
let(:doodad) { FactoryBot.create(:doodad) }
|
@@ -100,4 +99,3 @@ module WorksCited
|
|
100
99
|
end
|
101
100
|
end
|
102
101
|
end
|
103
|
-
# rubocop:enable Metrics/ModuleLength
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rails_helper'
|
2
4
|
|
3
5
|
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
@@ -12,6 +14,7 @@ require 'rails_helper'
|
|
12
14
|
# of tools you can use to make these specs even more expressive, but we're
|
13
15
|
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
14
16
|
|
17
|
+
# rubocop:disable Metrics/ModuleLength
|
15
18
|
module WorksCited
|
16
19
|
RSpec.describe '/citations', type: :request do
|
17
20
|
include Engine.routes.url_helpers
|
@@ -21,165 +24,197 @@ module WorksCited
|
|
21
24
|
|
22
25
|
# Citation. As you add validations to Citation, be sure to
|
23
26
|
# adjust the attributes here as well.
|
24
|
-
let(:valid_attributes)
|
27
|
+
let(:valid_attributes) do
|
25
28
|
{ citation_type: 'book', title: Faker::Book.title, record: "#{doodad.class.model_name}:#{doodad.id}" }
|
26
|
-
|
29
|
+
end
|
27
30
|
|
28
|
-
let(:invalid_attributes)
|
31
|
+
let(:invalid_attributes) do
|
29
32
|
{ citation_type: 'book', title: nil, record: nil }
|
30
|
-
|
33
|
+
end
|
31
34
|
|
32
|
-
describe '
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
sign_in admin
|
38
|
-
get citation_url(citation)
|
39
|
-
expect(response).to be_successful
|
35
|
+
describe 'when anonymous' do
|
36
|
+
describe 'GET /show' do
|
37
|
+
it 'disallows' do
|
38
|
+
expect { get citation_url(citation) }.to raise_error(CanCan::AccessDenied)
|
39
|
+
end
|
40
40
|
end
|
41
|
-
end
|
42
41
|
|
43
|
-
|
44
|
-
|
45
|
-
|
42
|
+
describe 'GET /index' do
|
43
|
+
before do
|
44
|
+
Citation.create! valid_attributes
|
45
|
+
end
|
46
|
+
it 'disallows' do
|
47
|
+
expect { get citations_url }.to raise_error(CanCan::AccessDenied)
|
48
|
+
end
|
46
49
|
end
|
47
|
-
|
48
|
-
|
50
|
+
|
51
|
+
describe 'GET /new' do
|
52
|
+
it 'disallows' do
|
53
|
+
expect { get new_citation_url }.to raise_error(CanCan::AccessDenied)
|
54
|
+
end
|
49
55
|
end
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
56
|
+
|
57
|
+
describe 'GET /edit' do
|
58
|
+
it 'disallows' do
|
59
|
+
expect { get edit_citation_url(citation) }.to raise_error(CanCan::AccessDenied)
|
60
|
+
end
|
54
61
|
end
|
55
|
-
end
|
56
62
|
|
57
|
-
|
58
|
-
|
59
|
-
|
63
|
+
describe 'PATCH /preview' do
|
64
|
+
it 'disallows' do
|
65
|
+
expect do
|
66
|
+
patch preview_citation_url, params: { citation: valid_attributes }
|
67
|
+
end.to raise_error(CanCan::AccessDenied)
|
68
|
+
end
|
60
69
|
end
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
70
|
+
|
71
|
+
describe 'POST /create' do
|
72
|
+
it 'disallows' do
|
73
|
+
expect { post citations_url, params: { citation: valid_attributes } }.to raise_error(CanCan::AccessDenied)
|
74
|
+
end
|
65
75
|
end
|
66
|
-
end
|
67
76
|
|
68
|
-
|
69
|
-
|
70
|
-
|
77
|
+
describe 'PATCH /update' do
|
78
|
+
let(:new_attributes) do
|
79
|
+
{ citation_type: 'book', title: 'New Title', record_id: doodad.id, record_type: 'Doodad' }
|
80
|
+
end
|
81
|
+
it 'disallows' do
|
82
|
+
expect do
|
83
|
+
patch citation_url(citation), params: { citation: new_attributes }
|
84
|
+
end.to raise_error(CanCan::AccessDenied)
|
85
|
+
end
|
71
86
|
end
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
87
|
+
|
88
|
+
describe 'DELETE /destroy' do
|
89
|
+
it 'disallows' do
|
90
|
+
expect { delete citation_url(citation) }.to raise_error(CanCan::AccessDenied)
|
91
|
+
end
|
76
92
|
end
|
77
93
|
end
|
78
94
|
|
79
|
-
describe '
|
80
|
-
|
81
|
-
|
95
|
+
describe 'when admin' do
|
96
|
+
before do
|
97
|
+
sign_in admin
|
82
98
|
end
|
83
|
-
describe '
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
sign_in admin
|
88
|
-
patch preview_citation_url, params: { citation: valid_attributes }
|
89
|
-
expect(response).to be_successful
|
90
|
-
end
|
99
|
+
describe 'GET /show' do
|
100
|
+
it 'renders a successful response when admin' do
|
101
|
+
get citation_url(citation)
|
102
|
+
expect(response).to be_successful
|
91
103
|
end
|
92
104
|
end
|
93
|
-
end
|
94
105
|
|
95
|
-
|
96
|
-
|
97
|
-
|
106
|
+
describe 'GET /index' do
|
107
|
+
before do
|
108
|
+
Citation.create! valid_attributes
|
109
|
+
end
|
110
|
+
it 'renders a successful response when admin' do
|
111
|
+
get citations_url
|
112
|
+
expect(response).to be_successful
|
113
|
+
end
|
98
114
|
end
|
99
|
-
describe 'when admin' do
|
100
|
-
before { sign_in admin }
|
101
|
-
context 'with valid parameters' do
|
102
|
-
it 'creates a new Citation' do
|
103
|
-
expect {
|
104
|
-
post citations_url, params: { citation: valid_attributes }
|
105
|
-
}.to change(Citation, :count).by(1)
|
106
|
-
end
|
107
115
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
116
|
+
describe 'GET /new' do
|
117
|
+
it 'renders a successful response when admin' do
|
118
|
+
get new_citation_url
|
119
|
+
expect(response).to be_successful
|
112
120
|
end
|
121
|
+
end
|
113
122
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
123
|
+
describe 'GET /edit' do
|
124
|
+
it 'render a successful response when admin' do
|
125
|
+
get edit_citation_url(citation)
|
126
|
+
expect(response).to be_successful
|
127
|
+
end
|
128
|
+
end
|
120
129
|
|
121
|
-
|
122
|
-
|
123
|
-
|
130
|
+
describe 'PATCH /preview' do
|
131
|
+
describe 'when admin' do
|
132
|
+
context 'with valid parameters' do
|
133
|
+
it 'previews the Citation' do
|
134
|
+
patch preview_citation_url, params: { citation: valid_attributes }
|
135
|
+
expect(response).to be_successful
|
136
|
+
end
|
124
137
|
end
|
125
138
|
end
|
126
139
|
end
|
127
|
-
end
|
128
140
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
before { sign_in admin }
|
138
|
-
context 'with valid parameters' do
|
141
|
+
describe 'POST /create' do
|
142
|
+
describe 'when admin' do
|
143
|
+
context 'with valid parameters' do
|
144
|
+
it 'creates a new Citation' do
|
145
|
+
expect do
|
146
|
+
post citations_url, params: { citation: valid_attributes }
|
147
|
+
end.to change(Citation, :count).by(1)
|
148
|
+
end
|
139
149
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
150
|
+
it 'redirects to the created citation' do
|
151
|
+
post citations_url, params: { citation: valid_attributes }
|
152
|
+
expect(response).to redirect_to(citation_url(Citation.last))
|
153
|
+
end
|
144
154
|
end
|
145
155
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
156
|
+
context 'with invalid parameters' do
|
157
|
+
it 'does not create a new Citation' do
|
158
|
+
expect do
|
159
|
+
post citations_url, params: { citation: invalid_attributes }
|
160
|
+
end.to change(Citation, :count).by(0)
|
161
|
+
end
|
152
162
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
163
|
+
it "renders a successful response (i.e. to display the 'new' template)" do
|
164
|
+
post citations_url, params: { citation: invalid_attributes }
|
165
|
+
expect(response).to be_successful
|
166
|
+
end
|
157
167
|
end
|
158
168
|
end
|
159
169
|
end
|
160
|
-
end
|
161
170
|
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
end
|
166
|
-
describe 'when admin' do
|
167
|
-
before do
|
168
|
-
sign_in admin
|
169
|
-
citation # Call it up so it exists ahead of time
|
171
|
+
describe 'PATCH /update' do
|
172
|
+
let(:new_attributes) do
|
173
|
+
{ citation_type: 'book', title: 'New Title', record_id: doodad.id, record_type: 'Doodad' }
|
170
174
|
end
|
175
|
+
describe 'when admin' do
|
176
|
+
context 'with valid parameters' do
|
177
|
+
it 'updates the requested citation' do
|
178
|
+
patch citation_url(citation), params: { citation: new_attributes }
|
179
|
+
citation.reload
|
180
|
+
expect(citation.title).to eq('New Title')
|
181
|
+
end
|
182
|
+
|
183
|
+
it 'redirects to the citation' do
|
184
|
+
patch citation_url(citation), params: { citation: new_attributes }
|
185
|
+
citation.reload
|
186
|
+
expect(response).to redirect_to(citation_url(citation))
|
187
|
+
end
|
188
|
+
end
|
171
189
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
190
|
+
context 'with invalid parameters' do
|
191
|
+
it "renders a successful response (i.e. to display the 'edit' template)" do
|
192
|
+
patch citation_url(citation), params: { citation: invalid_attributes }
|
193
|
+
expect(response).to be_successful
|
194
|
+
end
|
195
|
+
end
|
176
196
|
end
|
197
|
+
end
|
198
|
+
|
199
|
+
describe 'DELETE /destroy' do
|
200
|
+
describe 'when admin' do
|
201
|
+
before do
|
202
|
+
citation # Call it up so it exists ahead of time
|
203
|
+
end
|
177
204
|
|
178
|
-
|
179
|
-
|
180
|
-
|
205
|
+
it 'destroys the requested citation' do
|
206
|
+
expect do
|
207
|
+
delete citation_url(citation)
|
208
|
+
end.to change(Citation, :count).by(-1)
|
209
|
+
end
|
210
|
+
|
211
|
+
it 'redirects to the citations list' do
|
212
|
+
delete citation_url(citation)
|
213
|
+
expect(response).to redirect_to(citations_url)
|
214
|
+
end
|
181
215
|
end
|
182
216
|
end
|
183
217
|
end
|
184
218
|
end
|
185
219
|
end
|
220
|
+
# rubocop:enable Metrics/ModuleLength
|
data/works_cited.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: works_cited 0.1.
|
5
|
+
# stub: works_cited 0.1.5 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "works_cited".freeze
|
9
|
-
s.version = "0.1.
|
9
|
+
s.version = "0.1.5"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.metadata = { "source_code_uri" => "http://github.com/gemvein/works_cited" } if s.respond_to? :metadata=
|
@@ -15,7 +15,6 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.date = "2021-09-08"
|
16
16
|
s.description = "Works cited allows you to add a list of the works cited in ActiveRecord objects, to be formatted by a helper that can be added to relevant pages to format the citations like a bibliography.".freeze
|
17
17
|
s.email = "loren.lundgren@gmail.com".freeze
|
18
|
-
s.executables = ["rails".freeze]
|
19
18
|
s.extra_rdoc_files = [
|
20
19
|
"LICENSE.txt",
|
21
20
|
"README.md"
|
@@ -25,7 +24,6 @@ Gem::Specification.new do |s|
|
|
25
24
|
".rubocop.yml",
|
26
25
|
".ruby-gemset",
|
27
26
|
".ruby-version",
|
28
|
-
".travis.yml",
|
29
27
|
"Gemfile",
|
30
28
|
"Gemfile.lock",
|
31
29
|
"LICENSE.txt",
|
@@ -60,7 +58,6 @@ Gem::Specification.new do |s|
|
|
60
58
|
"app/views/works_cited/citations/preview.html.haml",
|
61
59
|
"app/views/works_cited/citations/show.html.haml",
|
62
60
|
"app/views/works_cited/contributors/_fields.html.haml",
|
63
|
-
"bin/rails",
|
64
61
|
"config/initializers/simple_form.rb",
|
65
62
|
"config/locales/simple_form.en.yml",
|
66
63
|
"config/routes.rb",
|
@@ -196,8 +193,8 @@ Gem::Specification.new do |s|
|
|
196
193
|
s.add_runtime_dependency(%q<haml-rails>.freeze, [">= 2.0", "< 3"])
|
197
194
|
s.add_runtime_dependency(%q<sass-rails>.freeze, [">= 6", "< 7"])
|
198
195
|
s.add_runtime_dependency(%q<cancancan>.freeze, [">= 3.3", "< 4"])
|
199
|
-
s.add_runtime_dependency(%q<vanilla_nested>.freeze, [">= 1.3", "< 2"])
|
200
196
|
s.add_runtime_dependency(%q<simple_form>.freeze, [">= 5.1", "< 6"])
|
197
|
+
s.add_runtime_dependency(%q<vanilla_nested>.freeze, [">= 1.3", "< 2"])
|
201
198
|
s.add_runtime_dependency(%q<kaminari>.freeze, [">= 1.2.1", "< 2"])
|
202
199
|
s.add_development_dependency(%q<database_cleaner>.freeze, [">= 1.8", "< 2"])
|
203
200
|
s.add_development_dependency(%q<devise>.freeze, [">= 4.8", "< 5"])
|
@@ -214,8 +211,8 @@ Gem::Specification.new do |s|
|
|
214
211
|
s.add_dependency(%q<haml-rails>.freeze, [">= 2.0", "< 3"])
|
215
212
|
s.add_dependency(%q<sass-rails>.freeze, [">= 6", "< 7"])
|
216
213
|
s.add_dependency(%q<cancancan>.freeze, [">= 3.3", "< 4"])
|
217
|
-
s.add_dependency(%q<vanilla_nested>.freeze, [">= 1.3", "< 2"])
|
218
214
|
s.add_dependency(%q<simple_form>.freeze, [">= 5.1", "< 6"])
|
215
|
+
s.add_dependency(%q<vanilla_nested>.freeze, [">= 1.3", "< 2"])
|
219
216
|
s.add_dependency(%q<kaminari>.freeze, [">= 1.2.1", "< 2"])
|
220
217
|
s.add_dependency(%q<database_cleaner>.freeze, [">= 1.8", "< 2"])
|
221
218
|
s.add_dependency(%q<devise>.freeze, [">= 4.8", "< 5"])
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: works_cited
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Loren Lundgren
|
@@ -91,45 +91,45 @@ dependencies:
|
|
91
91
|
- !ruby/object:Gem::Version
|
92
92
|
version: '4'
|
93
93
|
- !ruby/object:Gem::Dependency
|
94
|
-
name:
|
94
|
+
name: simple_form
|
95
95
|
requirement: !ruby/object:Gem::Requirement
|
96
96
|
requirements:
|
97
97
|
- - ">="
|
98
98
|
- !ruby/object:Gem::Version
|
99
|
-
version: '1
|
99
|
+
version: '5.1'
|
100
100
|
- - "<"
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: '
|
102
|
+
version: '6'
|
103
103
|
type: :runtime
|
104
104
|
prerelease: false
|
105
105
|
version_requirements: !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
107
107
|
- - ">="
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: '1
|
109
|
+
version: '5.1'
|
110
110
|
- - "<"
|
111
111
|
- !ruby/object:Gem::Version
|
112
|
-
version: '
|
112
|
+
version: '6'
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
|
-
name:
|
114
|
+
name: vanilla_nested
|
115
115
|
requirement: !ruby/object:Gem::Requirement
|
116
116
|
requirements:
|
117
117
|
- - ">="
|
118
118
|
- !ruby/object:Gem::Version
|
119
|
-
version: '
|
119
|
+
version: '1.3'
|
120
120
|
- - "<"
|
121
121
|
- !ruby/object:Gem::Version
|
122
|
-
version: '
|
122
|
+
version: '2'
|
123
123
|
type: :runtime
|
124
124
|
prerelease: false
|
125
125
|
version_requirements: !ruby/object:Gem::Requirement
|
126
126
|
requirements:
|
127
127
|
- - ">="
|
128
128
|
- !ruby/object:Gem::Version
|
129
|
-
version: '
|
129
|
+
version: '1.3'
|
130
130
|
- - "<"
|
131
131
|
- !ruby/object:Gem::Version
|
132
|
-
version: '
|
132
|
+
version: '2'
|
133
133
|
- !ruby/object:Gem::Dependency
|
134
134
|
name: kaminari
|
135
135
|
requirement: !ruby/object:Gem::Requirement
|
@@ -324,8 +324,7 @@ description: Works cited allows you to add a list of the works cited in ActiveRe
|
|
324
324
|
objects, to be formatted by a helper that can be added to relevant pages to format
|
325
325
|
the citations like a bibliography.
|
326
326
|
email: loren.lundgren@gmail.com
|
327
|
-
executables:
|
328
|
-
- rails
|
327
|
+
executables: []
|
329
328
|
extensions: []
|
330
329
|
extra_rdoc_files:
|
331
330
|
- LICENSE.txt
|
@@ -335,7 +334,6 @@ files:
|
|
335
334
|
- ".rubocop.yml"
|
336
335
|
- ".ruby-gemset"
|
337
336
|
- ".ruby-version"
|
338
|
-
- ".travis.yml"
|
339
337
|
- Gemfile
|
340
338
|
- Gemfile.lock
|
341
339
|
- LICENSE.txt
|
@@ -370,7 +368,6 @@ files:
|
|
370
368
|
- app/views/works_cited/citations/preview.html.haml
|
371
369
|
- app/views/works_cited/citations/show.html.haml
|
372
370
|
- app/views/works_cited/contributors/_fields.html.haml
|
373
|
-
- bin/rails
|
374
371
|
- config/initializers/simple_form.rb
|
375
372
|
- config/locales/simple_form.en.yml
|
376
373
|
- config/routes.rb
|