works_cited 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  FactoryBot.define do
2
4
  factory :user do
3
5
  email { Faker::Internet.email }
@@ -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 'GET /show' do
33
- it 'disallows when appropriate' do
34
- expect { get citation_url(citation) }.to raise_error(CanCan::AccessDenied)
35
- end
36
- it 'renders a successful response when admin' do
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
- describe 'GET /index' do
44
- before do
45
- Citation.create! valid_attributes
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
- it 'disallows when appropriate' do
48
- expect { get citations_url }.to raise_error(CanCan::AccessDenied)
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
- it 'renders a successful response when admin' do
51
- sign_in admin
52
- get citations_url
53
- expect(response).to be_successful
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
- describe 'GET /new' do
58
- it 'disallows when appropriate' do
59
- expect { get new_citation_url }.to raise_error(CanCan::AccessDenied)
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
- it 'renders a successful response when admin' do
62
- sign_in admin
63
- get new_citation_url
64
- expect(response).to be_successful
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
- describe 'GET /edit' do
69
- it 'disallows when appropriate' do
70
- expect { get edit_citation_url(citation) }.to raise_error(CanCan::AccessDenied)
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
- it 'render a successful response when admin' do
73
- sign_in admin
74
- get edit_citation_url(citation)
75
- expect(response).to be_successful
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 'PATCH /preview' do
80
- it 'disallows when appropriate' do
81
- expect { patch preview_citation_url, params: { citation: valid_attributes } }.to raise_error(CanCan::AccessDenied)
95
+ describe 'when admin' do
96
+ before do
97
+ sign_in admin
82
98
  end
83
- describe 'when admin' do
84
- before { sign_in admin }
85
- context 'with valid parameters' do
86
- it 'previews the Citation' do
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
- describe 'POST /create' do
96
- it 'disallows when appropriate' do
97
- expect { post citations_url, params: { citation: valid_attributes } }.to raise_error(CanCan::AccessDenied)
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
- it 'redirects to the created citation' do
109
- post citations_url, params: { citation: valid_attributes }
110
- expect(response).to redirect_to(citation_url(Citation.last))
111
- end
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
- context 'with invalid parameters' do
115
- it 'does not create a new Citation' do
116
- expect {
117
- post citations_url, params: { citation: invalid_attributes }
118
- }.to change(Citation, :count).by(0)
119
- end
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
- it "renders a successful response (i.e. to display the 'new' template)" do
122
- post citations_url, params: { citation: invalid_attributes }
123
- expect(response).to be_successful
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
- describe 'PATCH /update' do
130
- let(:new_attributes) {
131
- { citation_type: 'book', title: 'New Title', record_id: doodad.id, record_type: 'Doodad' }
132
- }
133
- it 'disallows when appropriate' do
134
- expect { patch citation_url(citation), params: { citation: new_attributes } }.to raise_error(CanCan::AccessDenied)
135
- end
136
- describe 'when admin' do
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
- it 'updates the requested citation' do
141
- patch citation_url(citation), params: { citation: new_attributes }
142
- citation.reload
143
- expect(citation.title).to eq('New Title')
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
- it 'redirects to the citation' do
147
- patch citation_url(citation), params: { citation: new_attributes }
148
- citation.reload
149
- expect(response).to redirect_to(citation_url(citation))
150
- end
151
- end
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
- context 'with invalid parameters' do
154
- it "renders a successful response (i.e. to display the 'edit' template)" do
155
- patch citation_url(citation), params: { citation: invalid_attributes }
156
- expect(response).to be_successful
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
- describe 'DELETE /destroy' do
163
- it 'disallows when appropriate' do
164
- expect { delete citation_url(citation) }.to raise_error(CanCan::AccessDenied)
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
- it 'destroys the requested citation' do
173
- expect {
174
- delete citation_url(citation)
175
- }.to change(Citation, :count).by(-1)
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
- it 'redirects to the citations list' do
179
- delete citation_url(citation)
180
- expect(response).to redirect_to(citations_url)
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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rails_helper'
2
4
 
3
5
  RSpec.describe WorksCited::CitationsController, type: :routing do
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.3 ruby lib
5
+ # stub: works_cited 0.1.4 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "works_cited".freeze
9
- s.version = "0.1.3"
9
+ s.version = "0.1.4"
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=
@@ -24,7 +24,6 @@ Gem::Specification.new do |s|
24
24
  ".rubocop.yml",
25
25
  ".ruby-gemset",
26
26
  ".ruby-version",
27
- ".travis.yml",
28
27
  "Gemfile",
29
28
  "Gemfile.lock",
30
29
  "LICENSE.txt",
@@ -194,8 +193,8 @@ Gem::Specification.new do |s|
194
193
  s.add_runtime_dependency(%q<haml-rails>.freeze, [">= 2.0", "< 3"])
195
194
  s.add_runtime_dependency(%q<sass-rails>.freeze, [">= 6", "< 7"])
196
195
  s.add_runtime_dependency(%q<cancancan>.freeze, [">= 3.3", "< 4"])
197
- s.add_runtime_dependency(%q<vanilla_nested>.freeze, [">= 1.3", "< 2"])
198
196
  s.add_runtime_dependency(%q<simple_form>.freeze, [">= 5.1", "< 6"])
197
+ s.add_runtime_dependency(%q<vanilla_nested>.freeze, [">= 1.3", "< 2"])
199
198
  s.add_runtime_dependency(%q<kaminari>.freeze, [">= 1.2.1", "< 2"])
200
199
  s.add_development_dependency(%q<database_cleaner>.freeze, [">= 1.8", "< 2"])
201
200
  s.add_development_dependency(%q<devise>.freeze, [">= 4.8", "< 5"])
@@ -212,8 +211,8 @@ Gem::Specification.new do |s|
212
211
  s.add_dependency(%q<haml-rails>.freeze, [">= 2.0", "< 3"])
213
212
  s.add_dependency(%q<sass-rails>.freeze, [">= 6", "< 7"])
214
213
  s.add_dependency(%q<cancancan>.freeze, [">= 3.3", "< 4"])
215
- s.add_dependency(%q<vanilla_nested>.freeze, [">= 1.3", "< 2"])
216
214
  s.add_dependency(%q<simple_form>.freeze, [">= 5.1", "< 6"])
215
+ s.add_dependency(%q<vanilla_nested>.freeze, [">= 1.3", "< 2"])
217
216
  s.add_dependency(%q<kaminari>.freeze, [">= 1.2.1", "< 2"])
218
217
  s.add_dependency(%q<database_cleaner>.freeze, [">= 1.8", "< 2"])
219
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.3
4
+ version: 0.1.4
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: vanilla_nested
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.3'
99
+ version: '5.1'
100
100
  - - "<"
101
101
  - !ruby/object:Gem::Version
102
- version: '2'
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.3'
109
+ version: '5.1'
110
110
  - - "<"
111
111
  - !ruby/object:Gem::Version
112
- version: '2'
112
+ version: '6'
113
113
  - !ruby/object:Gem::Dependency
114
- name: simple_form
114
+ name: vanilla_nested
115
115
  requirement: !ruby/object:Gem::Requirement
116
116
  requirements:
117
117
  - - ">="
118
118
  - !ruby/object:Gem::Version
119
- version: '5.1'
119
+ version: '1.3'
120
120
  - - "<"
121
121
  - !ruby/object:Gem::Version
122
- version: '6'
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: '5.1'
129
+ version: '1.3'
130
130
  - - "<"
131
131
  - !ruby/object:Gem::Version
132
- version: '6'
132
+ version: '2'
133
133
  - !ruby/object:Gem::Dependency
134
134
  name: kaminari
135
135
  requirement: !ruby/object:Gem::Requirement
@@ -334,7 +334,6 @@ files:
334
334
  - ".rubocop.yml"
335
335
  - ".ruby-gemset"
336
336
  - ".ruby-version"
337
- - ".travis.yml"
338
337
  - Gemfile
339
338
  - Gemfile.lock
340
339
  - LICENSE.txt