mumuki-laboratory 6.1.5 → 6.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/app/assets/javascripts/application.js +1 -0
- data/app/assets/javascripts/application/codemirror-builder.js +11 -1
- data/app/assets/javascripts/application/codemirror.js +0 -1
- data/app/assets/javascripts/application/discussions.js +15 -2
- data/app/assets/javascripts/application/free-form.js +1 -1
- data/app/assets/javascripts/application/kids.js +3 -3
- data/app/assets/javascripts/application/load-error-svg.js +1 -1
- data/app/controllers/invitations_controller.rb +1 -1
- data/app/helpers/application_helper.rb +0 -22
- data/app/helpers/assets_helper.rb +12 -0
- data/app/helpers/assignment_result_helper.rb +1 -1
- data/app/helpers/assistance_box_helper.rb +9 -0
- data/app/helpers/editor_helper.rb +13 -0
- data/app/helpers/locale_helper.rb +11 -0
- data/app/helpers/menu_bar_helper.rb +13 -0
- data/app/helpers/multiple_file_editor_helper.rb +5 -0
- data/app/helpers/open_graph_helper.rb +12 -0
- data/app/helpers/page_title_helper.rb +11 -0
- data/app/views/exercise_solutions/_kids_results.html.erb +1 -1
- data/app/views/exercises/_read_only.html.erb +3 -1
- data/app/views/invitations/show.html.erb +1 -1
- data/app/views/layouts/_kids.html.erb +1 -1
- data/app/views/layouts/_main.html.erb +5 -20
- data/app/views/layouts/application.html.erb +2 -7
- data/app/views/layouts/exercise_inputs/editors/_multiple_files.html.erb +11 -12
- data/app/views/layouts/exercise_inputs/layouts/_input_kids.html.erb +1 -1
- data/app/views/layouts/exercise_inputs/read_only_editors/_code.html.erb +1 -1
- data/app/views/layouts/exercise_inputs/read_only_editors/_free_form.html.erb +1 -1
- data/app/views/layouts/exercise_inputs/read_only_editors/_multiple_files.html.erb +29 -0
- data/app/views/layouts/mailer.html.erb +1 -1
- data/app/views/layouts/modals/_kids_context.html.erb +1 -1
- data/config/initializers/form_builder.rb +4 -5
- data/lib/events.rb +1 -4
- data/lib/mumuki/laboratory/locales/en.yml +0 -1
- data/lib/mumuki/laboratory/locales/es.yml +0 -1
- data/lib/mumuki/laboratory/locales/pt.yml +0 -1
- data/lib/mumuki/laboratory/version.rb +1 -1
- data/public/character/kids/{yellow_context.svg → kibi_context.svg} +2 -2
- data/public/{amarillo.svg → kibi.svg} +2 -2
- data/public/{anim_amarillo.svg → kibi_animated.svg} +2 -2
- data/public/{amarillo_fracaso.svg → kibi_failure.svg} +2 -2
- data/public/{amarillo_exito.svg → kibi_success.svg} +2 -2
- data/public/{amarillo_exito_bailarin.svg → kibi_success_dancing.svg} +2 -2
- data/spec/capybara_helper.rb +4 -4
- data/spec/helpers/application_helper_spec.rb +0 -16
- data/spec/helpers/page_title_helper_spec.rb +19 -0
- data/spec/spec_helper.rb +2 -1
- data/vendor/assets/javascripts/codemirror-autorefresh.js +46 -0
- metadata +76 -163
- data/spec/factories/api_client_factory.rb +0 -18
- data/spec/factories/assignments_factory.rb +0 -7
- data/spec/factories/book_factory.rb +0 -7
- data/spec/factories/chapter_factory.rb +0 -16
- data/spec/factories/complement_factory.rb +0 -6
- data/spec/factories/course_factory.rb +0 -9
- data/spec/factories/discussion_factory.rb +0 -8
- data/spec/factories/exam_factory.rb +0 -9
- data/spec/factories/exercise_factory.rb +0 -73
- data/spec/factories/guide_factory.rb +0 -30
- data/spec/factories/invitation_factory.rb +0 -7
- data/spec/factories/lesson_factory.rb +0 -7
- data/spec/factories/login_settings_factory.rb +0 -5
- data/spec/factories/message_factory.rb +0 -11
- data/spec/factories/organization_factory.rb +0 -26
- data/spec/factories/topic_factory.rb +0 -9
- data/spec/factories/user_factory.rb +0 -8
- data/spec/models/api_client_spec.rb +0 -6
- data/spec/models/assignment_spec.rb +0 -191
- data/spec/models/book_import_spec.rb +0 -49
- data/spec/models/book_spec.rb +0 -114
- data/spec/models/course_spec.rb +0 -22
- data/spec/models/discussion_spec.rb +0 -174
- data/spec/models/event_generation_spec.rb +0 -189
- data/spec/models/event_publishing_spec.rb +0 -36
- data/spec/models/exam_spec.rb +0 -151
- data/spec/models/exercise_spec.rb +0 -494
- data/spec/models/guide_import_spec.rb +0 -300
- data/spec/models/guide_spec.rb +0 -83
- data/spec/models/interactive_spec.rb +0 -143
- data/spec/models/language_spec.rb +0 -56
- data/spec/models/lesson_spec.rb +0 -90
- data/spec/models/message_spec.rb +0 -87
- data/spec/models/navigation_spec.rb +0 -70
- data/spec/models/organization_spec.rb +0 -124
- data/spec/models/playground_spec.rb +0 -23
- data/spec/models/problem_spec.rb +0 -80
- data/spec/models/query_spec.rb +0 -21
- data/spec/models/question_spec.rb +0 -37
- data/spec/models/reading_spec.rb +0 -10
- data/spec/models/solution_spec.rb +0 -66
- data/spec/models/stats_spec.rb +0 -15
- data/spec/models/string_spec.rb +0 -9
- data/spec/models/topic_import_spec.rb +0 -42
- data/spec/models/usage_spec.rb +0 -77
- data/spec/models/user_changed_spec.rb +0 -35
- data/spec/models/user_spec.rb +0 -276
- data/spec/models/with_expectations_spec.rb +0 -56
@@ -1,49 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Book, organization_workspace: :test do
|
4
|
-
let!(:haskell) { create(:haskell) }
|
5
|
-
let!(:gobstones) { create(:gobstones) }
|
6
|
-
|
7
|
-
let!(:guide_1) { create(:guide, name: 'a lesson') }
|
8
|
-
let!(:guide_2) { create(:guide, name: 'other lesson') }
|
9
|
-
|
10
|
-
let!(:topic_1) { create(:topic, name: 'a topic') }
|
11
|
-
let!(:topic_2) { create(:topic, name: 'other topic') }
|
12
|
-
|
13
|
-
let(:book) { Organization.current.book }
|
14
|
-
|
15
|
-
let(:book_resource_h) do
|
16
|
-
{name: 'sample book',
|
17
|
-
description: 'a sample book description',
|
18
|
-
slug: 'mumuki/mumuki-sample-book',
|
19
|
-
locale: 'en',
|
20
|
-
chapters: [topic_1.slug, topic_2.slug],
|
21
|
-
complements: complement_slugs,
|
22
|
-
}
|
23
|
-
end
|
24
|
-
|
25
|
-
describe '#import_from_resource_h!' do
|
26
|
-
context 'when complements are present' do
|
27
|
-
let(:complement_slugs) { [guide_2.slug, guide_1.slug] }
|
28
|
-
|
29
|
-
before { book.import_from_resource_h!(book_resource_h) }
|
30
|
-
|
31
|
-
it { expect(book.name).to eq 'sample book' }
|
32
|
-
it { expect(book.description).to eq 'a sample book description' }
|
33
|
-
it { expect(book.locale).to eq 'en' }
|
34
|
-
it { expect(book.chapters.count).to eq 2 }
|
35
|
-
it { expect(book.complements.count).to eq 2 }
|
36
|
-
|
37
|
-
it { expect(topic_2.reload.usage_in_organization).to be_a Chapter }
|
38
|
-
it { expect(guide_2.reload.usage_in_organization).to be_a Complement }
|
39
|
-
end
|
40
|
-
|
41
|
-
context 'when complements are not present' do
|
42
|
-
let(:complement_slugs) { ['foo/bar', guide_1.slug] }
|
43
|
-
|
44
|
-
before { book.import_from_resource_h!(book_resource_h) }
|
45
|
-
|
46
|
-
it { expect(book.complements.count).to eq 1 }
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
data/spec/models/book_spec.rb
DELETED
@@ -1,114 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Book, organization_workspace: :test do
|
4
|
-
let(:book) { Organization.current.book }
|
5
|
-
|
6
|
-
describe '#next_lesson_for' do
|
7
|
-
let!(:chapter) { create(:chapter, lessons: [create(:lesson)]) }
|
8
|
-
let(:fresh_user) { create(:user) }
|
9
|
-
|
10
|
-
before { reindex_current_organization! }
|
11
|
-
|
12
|
-
it { expect(book.next_lesson_for(nil)).to eq book.first_lesson }
|
13
|
-
it { expect(book.next_lesson_for(fresh_user)).to eq book.first_lesson }
|
14
|
-
end
|
15
|
-
|
16
|
-
describe '#rebuild!' do
|
17
|
-
let(:chapter_1) { build(:chapter, number: 10) }
|
18
|
-
let(:chapter_2) { build(:chapter, number: 8) }
|
19
|
-
|
20
|
-
let(:lesson_1) { create(:lesson) }
|
21
|
-
let(:lesson_2) { create(:lesson) }
|
22
|
-
let(:lesson_3) { create(:lesson) }
|
23
|
-
|
24
|
-
let(:guide_1) { lesson_1.guide }
|
25
|
-
let(:guide_2) { lesson_2.guide }
|
26
|
-
let(:guide_3) { lesson_3.guide }
|
27
|
-
|
28
|
-
context 'when chapter is rebuilt after book rebuilt' do
|
29
|
-
before do
|
30
|
-
book.description = '#foo'
|
31
|
-
book.rebuild!([chapter_1, chapter_2])
|
32
|
-
|
33
|
-
chapter_1.rebuild!([lesson_1, lesson_2])
|
34
|
-
chapter_2.rebuild!([lesson_3])
|
35
|
-
end
|
36
|
-
|
37
|
-
it { expect(book.description).to eq '#foo' }
|
38
|
-
it { expect(book.description_html).to eq "<h1>foo</h1>\n" }
|
39
|
-
|
40
|
-
it { expect(Chapter.count).to eq 2 }
|
41
|
-
it { expect(book.chapters).to eq [chapter_1, chapter_2] }
|
42
|
-
it { expect(chapter_1.guides).to eq [guide_1, guide_2] }
|
43
|
-
it { expect(chapter_2.guides).to eq [guide_3] }
|
44
|
-
it { expect(chapter_1.number).to eq 1 }
|
45
|
-
it { expect(chapter_2.number).to eq 2 }
|
46
|
-
end
|
47
|
-
|
48
|
-
context 'when some chapters are orphan' do
|
49
|
-
let(:orphan_chapter) { build(:chapter, book: nil) }
|
50
|
-
before do
|
51
|
-
book.description = '#foo'
|
52
|
-
book.rebuild!([chapter_1, orphan_chapter, chapter_2])
|
53
|
-
|
54
|
-
chapter_1.rebuild!([lesson_1, lesson_2])
|
55
|
-
chapter_2.rebuild!([lesson_3])
|
56
|
-
end
|
57
|
-
|
58
|
-
it { expect(book.description).to eq '#foo' }
|
59
|
-
it { expect(book.description_html).to eq "<h1>foo</h1>\n" }
|
60
|
-
|
61
|
-
it { expect(Chapter.count).to eq 3 }
|
62
|
-
it { expect(book.chapters).to eq [chapter_1, orphan_chapter, chapter_2] }
|
63
|
-
it { expect(chapter_1.guides).to eq [guide_1, guide_2] }
|
64
|
-
it { expect(chapter_2.guides).to eq [guide_3] }
|
65
|
-
it { expect(chapter_1.number).to eq 1 }
|
66
|
-
it { expect(orphan_chapter.number).to eq 2 }
|
67
|
-
it { expect(chapter_2.number).to eq 3 }
|
68
|
-
end
|
69
|
-
|
70
|
-
|
71
|
-
context 'when chapter is created before book rebuilt' do
|
72
|
-
before do
|
73
|
-
chapter_1.save!
|
74
|
-
chapter_2.save!
|
75
|
-
|
76
|
-
book.description = '#foo'
|
77
|
-
book.rebuild!([chapter_1, chapter_2])
|
78
|
-
|
79
|
-
chapter_1.rebuild!([lesson_1, lesson_2])
|
80
|
-
chapter_2.rebuild!([lesson_3])
|
81
|
-
end
|
82
|
-
|
83
|
-
it { expect(book.description).to eq '#foo' }
|
84
|
-
it { expect(book.description_html).to eq "<h1>foo</h1>\n" }
|
85
|
-
|
86
|
-
it { expect(Chapter.count).to eq 2 }
|
87
|
-
it { expect(book.chapters).to eq [chapter_1, chapter_2] }
|
88
|
-
it { expect(chapter_1.guides).to eq [guide_1, guide_2] }
|
89
|
-
it { expect(chapter_2.guides).to eq [guide_3] }
|
90
|
-
it { expect(chapter_1.number).to eq 1 }
|
91
|
-
it { expect(chapter_2.number).to eq 2 }
|
92
|
-
end
|
93
|
-
|
94
|
-
context 'when chapter is rebuilt before book rebuilt' do
|
95
|
-
before do
|
96
|
-
chapter_1.rebuild!([lesson_1, lesson_2])
|
97
|
-
chapter_2.rebuild!([lesson_3])
|
98
|
-
|
99
|
-
book.description = '#foo'
|
100
|
-
book.rebuild!([chapter_1, chapter_2])
|
101
|
-
end
|
102
|
-
|
103
|
-
it { expect(book.description).to eq '#foo' }
|
104
|
-
it { expect(book.description_html).to eq "<h1>foo</h1>\n" }
|
105
|
-
|
106
|
-
it { expect(Chapter.count).to eq 2 }
|
107
|
-
it { expect(book.chapters).to eq [chapter_1, chapter_2] }
|
108
|
-
it { expect(chapter_1.number).to eq 1 }
|
109
|
-
it { expect(chapter_2.number).to eq 2 }
|
110
|
-
it { expect(chapter_1.guides).to eq [guide_1, guide_2] }
|
111
|
-
it { expect(chapter_2.guides).to eq [guide_3] }
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
data/spec/models/course_spec.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'CourseChanged', organization_workspace: :test do
|
4
|
-
let(:course_json) do
|
5
|
-
{slug: 'test/bar',
|
6
|
-
shifts: %w(morning),
|
7
|
-
code: 'k2003',
|
8
|
-
days: %w(monday wednesday),
|
9
|
-
period: '2016',
|
10
|
-
description: 'test course'}
|
11
|
-
end
|
12
|
-
|
13
|
-
let!(:course) { Course.import_from_resource_h! course_json }
|
14
|
-
|
15
|
-
it { expect(course.organization.courses).to include course }
|
16
|
-
it { expect(course.organization.name).to eq 'test' }
|
17
|
-
|
18
|
-
it { expect(course.slug).to eq 'test/bar' }
|
19
|
-
it { expect(course.code).to eq 'k2003' }
|
20
|
-
it { expect(course.days).to eq %w(monday wednesday) }
|
21
|
-
it { expect(course.period).to eq '2016' }
|
22
|
-
end
|
@@ -1,174 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Discussion, organization_workspace: :test do
|
4
|
-
|
5
|
-
context 'when created' do
|
6
|
-
let(:initiator) { create(:user) }
|
7
|
-
let(:student) { create(:user) }
|
8
|
-
let(:problem) { create(:problem) }
|
9
|
-
let(:discussion) { problem.discuss! initiator, title: 'Need help' }
|
10
|
-
let(:moderator) { create(:user, permissions: {moderator: 'private/*'}) }
|
11
|
-
|
12
|
-
it { expect(discussion.new_record?).to be false }
|
13
|
-
it { expect(discussion.has_responses?).to be false }
|
14
|
-
it { expect(discussion.messages).to eq [] }
|
15
|
-
it { expect(discussion.initiator).to eq initiator }
|
16
|
-
it { expect(discussion.title).to eq 'Need help' }
|
17
|
-
it { expect(discussion.item).to eq problem }
|
18
|
-
it { expect(initiator.subscribed_to? discussion).to be true }
|
19
|
-
it { expect(discussion.status).to eq :opened }
|
20
|
-
it { expect(discussion.reachable_statuses_for initiator).to eq [:closed] }
|
21
|
-
it { expect(discussion.reachable_statuses_for moderator).to eq [:closed] }
|
22
|
-
it { expect(discussion.reachable_statuses_for student).to eq [] }
|
23
|
-
it { expect(discussion.commentable_by? student).to be true }
|
24
|
-
it { expect(discussion.commentable_by? moderator).to be true }
|
25
|
-
|
26
|
-
describe 'initiator sends a message' do
|
27
|
-
before { discussion.submit_message!({content: 'I forgot to say this'}, initiator) }
|
28
|
-
|
29
|
-
it { expect(discussion.has_responses?).to be false }
|
30
|
-
it { expect(discussion.messages.first.content).to eq 'I forgot to say this' }
|
31
|
-
it { expect(initiator.unread_discussions).to eq [] }
|
32
|
-
it { expect(discussion.reachable_statuses_for initiator).to eq [:closed] }
|
33
|
-
it { expect(discussion.reachable_statuses_for moderator).to eq [:closed] }
|
34
|
-
it { expect(discussion.reachable_statuses_for student).to eq [] }
|
35
|
-
|
36
|
-
describe 'and closes the discussion' do
|
37
|
-
before { discussion.update_status!(:closed, initiator) }
|
38
|
-
|
39
|
-
it { expect(discussion.status).to eq :closed }
|
40
|
-
it { expect(discussion.reachable_statuses_for initiator).to eq [] }
|
41
|
-
it { expect(discussion.reachable_statuses_for moderator).to eq [:opened, :solved] }
|
42
|
-
it { expect(discussion.reachable_statuses_for student).to eq [] }
|
43
|
-
it { expect(discussion.commentable_by? student).to be false }
|
44
|
-
it { expect(discussion.commentable_by? moderator).to be true }
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe 'receive message from helper' do
|
49
|
-
before { discussion.submit_message!({content: 'You should do this'}, student) }
|
50
|
-
|
51
|
-
it { expect(discussion.has_responses?).to be true }
|
52
|
-
it { expect(initiator.unread_discussions).to include discussion }
|
53
|
-
it { expect(discussion.messages.first.content).to eq 'You should do this' }
|
54
|
-
it { expect(discussion.reachable_statuses_for initiator).to eq [:pending_review] }
|
55
|
-
it { expect(discussion.reachable_statuses_for moderator).to eq [:closed, :solved] }
|
56
|
-
it { expect(discussion.reachable_statuses_for student).to eq [] }
|
57
|
-
|
58
|
-
describe 'gets updated to pending_review by initiator' do
|
59
|
-
before { discussion.update_status!(:pending_review, initiator) }
|
60
|
-
|
61
|
-
it { expect(discussion.status).to eq :pending_review }
|
62
|
-
it { expect(discussion.reachable_statuses_for initiator).to eq [] }
|
63
|
-
it { expect(discussion.reachable_statuses_for moderator).to eq [:opened, :closed, :solved] }
|
64
|
-
it { expect(discussion.reachable_statuses_for student).to eq [] }
|
65
|
-
it { expect(discussion.commentable_by? student).to be false }
|
66
|
-
it { expect(discussion.commentable_by? moderator).to be true }
|
67
|
-
end
|
68
|
-
|
69
|
-
describe 'initiator tries to solve it' do
|
70
|
-
it { expect { discussion.update_status!(:solved, initiator) }.not_to change(discussion, :status) }
|
71
|
-
end
|
72
|
-
|
73
|
-
describe 'gets solved by moderator' do
|
74
|
-
before { discussion.update_status!(:solved, moderator) }
|
75
|
-
|
76
|
-
it { expect(discussion.status).to eq :solved }
|
77
|
-
it { expect(discussion.reachable_statuses_for initiator).to eq [] }
|
78
|
-
it { expect(discussion.reachable_statuses_for moderator).to eq [:opened, :closed] }
|
79
|
-
it { expect(discussion.reachable_statuses_for student).to eq [] }
|
80
|
-
it { expect(discussion.commentable_by? student).to be false }
|
81
|
-
it { expect(discussion.commentable_by? moderator).to be true }
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
describe '#toggle_subscription!' do
|
87
|
-
context 'when the student is not subscribed' do
|
88
|
-
let(:discussion) { create(:discussion) }
|
89
|
-
let(:student) { create(:user) }
|
90
|
-
|
91
|
-
before { student.toggle_subscription!(discussion) }
|
92
|
-
|
93
|
-
it { expect(student.subscribed_to? discussion).to be true }
|
94
|
-
end
|
95
|
-
|
96
|
-
context 'when the student is subscribed' do
|
97
|
-
let(:discussion) { create(:discussion) }
|
98
|
-
let(:student) { create(:user, watched_discussions: [discussion]) }
|
99
|
-
|
100
|
-
before { student.toggle_subscription!(discussion) }
|
101
|
-
|
102
|
-
it { expect(student.subscribed_to? discussion).to be false }
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
describe '#toggle_upvote!' do
|
107
|
-
context 'when the student has not upvoted' do
|
108
|
-
let(:discussion) { create(:discussion) }
|
109
|
-
let(:student) { create(:user) }
|
110
|
-
|
111
|
-
before { student.toggle_upvote!(discussion) }
|
112
|
-
|
113
|
-
it { expect(student.upvoted? discussion).to be true }
|
114
|
-
it { expect(discussion.reload.upvotes_count).to be 1 }
|
115
|
-
end
|
116
|
-
|
117
|
-
context 'when the student is subscribed' do
|
118
|
-
let(:discussion) { create(:discussion) }
|
119
|
-
let(:student) { create(:user, upvoted_discussions: [discussion]) }
|
120
|
-
|
121
|
-
before { student.toggle_upvote!(discussion) }
|
122
|
-
|
123
|
-
it { expect(student.upvoted? discussion).to be false }
|
124
|
-
it { expect(discussion.reload.upvotes_count).to be 0 }
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
describe '#debatable_for' do
|
129
|
-
let(:exercise) { create(:problem) }
|
130
|
-
|
131
|
-
it { expect(described_class.debatable_for('Exercise', {exercise_id: exercise.id})).to eq exercise }
|
132
|
-
end
|
133
|
-
|
134
|
-
describe 'scope for user' do
|
135
|
-
let(:initiator) { create(:user) }
|
136
|
-
let(:exercise) { create(:problem) }
|
137
|
-
|
138
|
-
let!(:public_discussions) { [:opened, :solved].map { |it| create(:discussion, {status: it, initiator: initiator, item: exercise}) } }
|
139
|
-
let!(:private_discussions) { [:pending_review, :closed].map { |it| create(:discussion, {status: it, initiator: initiator, item: exercise}) } }
|
140
|
-
let!(:other_discussion) { create(:discussion, { status: :closed, item: exercise }) }
|
141
|
-
|
142
|
-
context 'as student' do
|
143
|
-
let(:student) { create(:user) }
|
144
|
-
it { expect(exercise.discussions.for_user(student)).to match_array public_discussions }
|
145
|
-
end
|
146
|
-
|
147
|
-
context 'as initiator' do
|
148
|
-
it { expect(exercise.discussions.for_user(initiator)).to match_array public_discussions + private_discussions }
|
149
|
-
end
|
150
|
-
|
151
|
-
context 'as moderator' do
|
152
|
-
let(:moderator) { create(:user, permissions: {moderator: 'private/*'}) }
|
153
|
-
it { expect(exercise.discussions.for_user(moderator)).to match_array public_discussions + private_discussions + [other_discussion] }
|
154
|
-
end
|
155
|
-
|
156
|
-
context 'for other item' do
|
157
|
-
let(:other_exercise) { create(:exercise) }
|
158
|
-
it { expect(other_exercise.discussions.for_user(initiator)).to be_empty }
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
describe 'messages not being deleted' do
|
163
|
-
let(:user) { create(:user) }
|
164
|
-
let(:other_user) { create(:user) }
|
165
|
-
let(:problem) { create(:problem) }
|
166
|
-
let(:assignment) { problem.submit_solution! user }
|
167
|
-
let(:discussion) { problem.discuss!(user, {title: 'A discussion'})}
|
168
|
-
|
169
|
-
before { discussion.submit_message!({content: 'You should do this'}, user) }
|
170
|
-
before { problem.submit_solution! other_user }
|
171
|
-
|
172
|
-
it { expect(discussion.messages.count).to eq 1 }
|
173
|
-
end
|
174
|
-
end
|
@@ -1,189 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe '#to_resource_h', organization_workspace: :test do
|
4
|
-
describe Assignment do
|
5
|
-
let(:user) {
|
6
|
-
create(:user,
|
7
|
-
id: 2, email: 'foo@bar.com',
|
8
|
-
first_name: 'Homer', last_name: 'Simpson',
|
9
|
-
provider: 'auth0', social_id: 'github|gh1234') }
|
10
|
-
describe 'lesson type' do
|
11
|
-
let(:lesson) { chapter.lessons.fourth }
|
12
|
-
let(:guide) { lesson.guide }
|
13
|
-
let(:exercise) { lesson.exercises.first }
|
14
|
-
let!(:chapter) {
|
15
|
-
create(:chapter, lessons: [
|
16
|
-
create(:lesson),
|
17
|
-
create(:lesson),
|
18
|
-
create(:lesson),
|
19
|
-
create(:lesson, exercises: [create(:exercise)])]) }
|
20
|
-
|
21
|
-
before { reindex_current_organization! }
|
22
|
-
|
23
|
-
let(:assignment) { create(:assignment,
|
24
|
-
solution: 'x = 2',
|
25
|
-
status: :passed,
|
26
|
-
submissions_count: 2,
|
27
|
-
submitter: user,
|
28
|
-
submission_id: 'abcd1234',
|
29
|
-
exercise: exercise) }
|
30
|
-
|
31
|
-
it { expect(lesson.number).to eq 4 }
|
32
|
-
it do
|
33
|
-
expect(assignment.to_resource_h).to json_like(
|
34
|
-
status: :passed,
|
35
|
-
result: nil,
|
36
|
-
expectation_results: [],
|
37
|
-
queries: [],
|
38
|
-
query_results: [],
|
39
|
-
feedback: nil,
|
40
|
-
test_results: nil,
|
41
|
-
submissions_count: 2,
|
42
|
-
attemps_count: 0,
|
43
|
-
manual_evaluation_comment: nil,
|
44
|
-
exercise: {
|
45
|
-
eid: exercise.bibliotheca_id,
|
46
|
-
name: exercise.name,
|
47
|
-
number: exercise.number},
|
48
|
-
guide: {
|
49
|
-
name: guide.name,
|
50
|
-
slug: guide.slug,
|
51
|
-
lesson: {
|
52
|
-
number: 4,
|
53
|
-
},
|
54
|
-
language: {
|
55
|
-
name: guide.language.name
|
56
|
-
},
|
57
|
-
parent: {
|
58
|
-
type: 'Lesson',
|
59
|
-
name: guide.name,
|
60
|
-
position: 4,
|
61
|
-
chapter: {
|
62
|
-
id: guide.chapter.id,
|
63
|
-
name: guide.chapter.name
|
64
|
-
}
|
65
|
-
}
|
66
|
-
},
|
67
|
-
submitter: {
|
68
|
-
social_id: 'github|gh1234',
|
69
|
-
name: 'Homer Simpson',
|
70
|
-
email: 'foo@bar.com',
|
71
|
-
uid: assignment.submitter.uid,
|
72
|
-
image_url: 'user_shape.png'},
|
73
|
-
sid: 'abcd1234',
|
74
|
-
created_at: assignment.updated_at,
|
75
|
-
content: 'x = 2',
|
76
|
-
organization: 'test')
|
77
|
-
end
|
78
|
-
end
|
79
|
-
describe 'exam type' do
|
80
|
-
let!(:exam) { create(:exam, guide: create(:guide, exercises: [create(:exercise)])) }
|
81
|
-
let(:guide) { exam.guide }
|
82
|
-
let(:exercise) { guide.exercises.first }
|
83
|
-
before { reindex_current_organization! }
|
84
|
-
let(:assignment) { create(:assignment,
|
85
|
-
solution: 'x = 2',
|
86
|
-
status: :passed,
|
87
|
-
submissions_count: 2,
|
88
|
-
submitter: user,
|
89
|
-
submission_id: 'abcd1234',
|
90
|
-
exercise: exercise) }
|
91
|
-
it do
|
92
|
-
expect(assignment.to_resource_h).to json_like(
|
93
|
-
status: :passed,
|
94
|
-
result: nil,
|
95
|
-
expectation_results: [],
|
96
|
-
queries: [],
|
97
|
-
query_results: [],
|
98
|
-
feedback: nil,
|
99
|
-
test_results: nil,
|
100
|
-
submissions_count: 2,
|
101
|
-
attemps_count: 0,
|
102
|
-
manual_evaluation_comment: nil,
|
103
|
-
exercise: {
|
104
|
-
name: exercise.name,
|
105
|
-
number: exercise.number,
|
106
|
-
eid: exercise.bibliotheca_id},
|
107
|
-
guide: {
|
108
|
-
name: guide.name,
|
109
|
-
slug: guide.slug,
|
110
|
-
language: {
|
111
|
-
name: guide.language.name
|
112
|
-
},
|
113
|
-
parent: {
|
114
|
-
type: 'Exam',
|
115
|
-
name: guide.name,
|
116
|
-
position: nil,
|
117
|
-
chapter: nil
|
118
|
-
}
|
119
|
-
},
|
120
|
-
submitter: {
|
121
|
-
social_id: 'github|gh1234',
|
122
|
-
name: 'Homer Simpson',
|
123
|
-
email: 'foo@bar.com',
|
124
|
-
image_url: 'user_shape.png',
|
125
|
-
uid: assignment.submitter.uid},
|
126
|
-
sid: 'abcd1234',
|
127
|
-
created_at: assignment.updated_at,
|
128
|
-
content: 'x = 2',
|
129
|
-
organization: 'test')
|
130
|
-
|
131
|
-
end
|
132
|
-
end
|
133
|
-
describe 'complementary type' do
|
134
|
-
let!(:complement) { create(:complement, guide: create(:guide, exercises: [create(:exercise)])) }
|
135
|
-
let(:guide) { complement.guide }
|
136
|
-
let(:exercise) { guide.exercises.first }
|
137
|
-
before { reindex_current_organization! }
|
138
|
-
let(:assignment) { create(:assignment,
|
139
|
-
solution: 'x = 2',
|
140
|
-
status: :passed,
|
141
|
-
submissions_count: 2,
|
142
|
-
submitter: user,
|
143
|
-
submission_id: 'abcd1234',
|
144
|
-
exercise: exercise) }
|
145
|
-
|
146
|
-
it do
|
147
|
-
expect(assignment.to_resource_h).to json_like(
|
148
|
-
status: :passed,
|
149
|
-
result: nil,
|
150
|
-
expectation_results: [],
|
151
|
-
queries: [],
|
152
|
-
query_results: [],
|
153
|
-
feedback: nil,
|
154
|
-
test_results: nil,
|
155
|
-
submissions_count: 2,
|
156
|
-
attemps_count: 0,
|
157
|
-
manual_evaluation_comment: nil,
|
158
|
-
exercise: {
|
159
|
-
eid: exercise.bibliotheca_id,
|
160
|
-
name: exercise.name,
|
161
|
-
number: exercise.number},
|
162
|
-
guide: {
|
163
|
-
name: guide.name,
|
164
|
-
slug: guide.slug,
|
165
|
-
language: {
|
166
|
-
name: guide.language.name
|
167
|
-
},
|
168
|
-
parent: {
|
169
|
-
type: 'Complement',
|
170
|
-
name: guide.name,
|
171
|
-
position: nil,
|
172
|
-
chapter: nil
|
173
|
-
}
|
174
|
-
},
|
175
|
-
submitter: {
|
176
|
-
name: 'Homer Simpson',
|
177
|
-
email: 'foo@bar.com',
|
178
|
-
image_url: 'user_shape.png',
|
179
|
-
uid: assignment.submitter.uid,
|
180
|
-
social_id: 'github|gh1234'},
|
181
|
-
sid: 'abcd1234',
|
182
|
-
created_at: assignment.updated_at,
|
183
|
-
content: 'x = 2',
|
184
|
-
organization: 'test')
|
185
|
-
|
186
|
-
end
|
187
|
-
end
|
188
|
-
end
|
189
|
-
end
|