|
84 | 84 |
|
85 | 85 | expect(described_class.action_allowed?(:new_version, app, exercise)).to eq false |
86 | 86 | end |
| 87 | + it 'cannot be accessed even by an author' do |
| 88 | + author = FactoryBot.create(:author, publication: exercise.publication, user: user) |
| 89 | + expect(described_class.action_allowed?(:new_version, user, exercise)).to eq false |
| 90 | + end |
87 | 91 | end |
88 | 92 |
|
89 | 93 | context 'not vocab exercise' do |
|
116 | 120 | expect(described_class.action_allowed?(:update, app, exercise)).to eq false |
117 | 121 | expect(described_class.action_allowed?(:destroy, app, exercise)).to eq false |
118 | 122 | end |
| 123 | + it 'can be accessed by an author' do |
| 124 | + author = FactoryBot.create(:author, publication: exercise.publication, user: user) |
| 125 | + expect(described_class.action_allowed?(:update, user, exercise)).to eq true |
| 126 | + expect(described_class.action_allowed?(:destroy, user, exercise)).to eq true |
| 127 | + end |
119 | 128 | end |
120 | 129 |
|
121 | 130 | context 'not vocab' do |
|
197 | 206 | exercise.vocab_term = FactoryBot.create :vocab_term |
198 | 207 | exercise.publication.published_at = Time.now |
199 | 208 | exercise.publication.save! |
| 209 | + exercise.save! |
200 | 210 | end |
201 | 211 |
|
202 | 212 | it 'cannot be accessed by anyone' do |
|
206 | 216 |
|
207 | 217 | expect(described_class.action_allowed?(:new_version, app, exercise)).to eq false |
208 | 218 | end |
| 219 | + it 'can be accessed by an author' do |
| 220 | + author = FactoryBot.create(:author, publication: exercise.publication, user: user) |
| 221 | + expect(described_class.action_allowed?(:new_version, user, exercise.reload)).to eq true |
| 222 | + end |
209 | 223 | end |
210 | 224 |
|
211 | 225 | context 'not vocab' do |
|
0 commit comments