mumuki-laboratory 7.7.6 → 7.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +83 -3
- data/Rakefile +7 -1
- data/app/assets/javascripts/mumuki_laboratory/application/alias-modes.js +1 -1
- data/app/assets/javascripts/mumuki_laboratory/application/bridge.js +66 -57
- data/app/assets/javascripts/mumuki_laboratory/application/codemirror-builder.js +28 -25
- data/app/assets/javascripts/mumuki_laboratory/application/codemirror.js +8 -10
- data/app/assets/javascripts/mumuki_laboratory/application/confirmation.js +2 -2
- data/app/assets/javascripts/mumuki_laboratory/application/console.js +41 -43
- data/app/assets/javascripts/mumuki_laboratory/application/csrf-token.js +9 -12
- data/app/assets/javascripts/mumuki_laboratory/application/custom-editor.js +11 -15
- data/app/assets/javascripts/mumuki_laboratory/application/discussions.js +1 -3
- data/app/assets/javascripts/mumuki_laboratory/application/editors.js +104 -0
- data/app/assets/javascripts/mumuki_laboratory/application/elipsis.js +5 -4
- data/app/assets/javascripts/mumuki_laboratory/application/events.js +51 -0
- data/app/assets/javascripts/mumuki_laboratory/application/exercise.js +68 -0
- data/app/assets/javascripts/mumuki_laboratory/application/inputs.js +4 -2
- data/app/assets/javascripts/mumuki_laboratory/application/interval.js +2 -4
- data/app/assets/javascripts/mumuki_laboratory/application/kids.js +1 -1
- data/app/assets/javascripts/mumuki_laboratory/application/load-analytics.js +1 -1
- data/app/assets/javascripts/mumuki_laboratory/application/load-error-svg.js +1 -1
- data/app/assets/javascripts/mumuki_laboratory/application/messages.js +2 -2
- data/app/assets/javascripts/mumuki_laboratory/application/multiple-choice.js +1 -1
- data/app/assets/javascripts/mumuki_laboratory/application/multiple-scenarios.js +3 -6
- data/app/assets/javascripts/mumuki_laboratory/application/pin.js +3 -5
- data/app/assets/javascripts/mumuki_laboratory/application/profile.js +71 -0
- data/app/assets/javascripts/mumuki_laboratory/application/progress.js +24 -6
- data/app/assets/javascripts/mumuki_laboratory/application/results-renderer.js +20 -11
- data/app/assets/javascripts/mumuki_laboratory/application/speech-bubble-renderer.js +12 -5
- data/app/assets/javascripts/mumuki_laboratory/application/submission.js +19 -101
- data/app/assets/javascripts/mumuki_laboratory/application/submissions-store.js +93 -0
- data/app/assets/javascripts/mumuki_laboratory/application/sync-mode.js +75 -0
- data/app/assets/javascripts/mumuki_laboratory/application/timer.js +5 -6
- data/app/assets/javascripts/mumuki_laboratory/application/tooltip.js +1 -1
- data/app/assets/javascripts/mumuki_laboratory/application/upload.js +1 -1
- data/app/assets/javascripts/mumuki_laboratory/application/user.js +1 -1
- data/app/assets/stylesheets/mumuki_laboratory/application.scss +1 -1
- data/app/assets/stylesheets/mumuki_laboratory/application/_modules.scss +19 -17
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_avatar.scss +41 -0
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_gs-board.scss +3 -0
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/{guide-corollary.scss → _guide_corollary.scss} +0 -0
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_kids.scss +1 -2
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_kindergarten.scss +2 -1
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/{popover.scss → _popover.scss} +0 -0
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_user_profile.scss +36 -0
- data/app/controllers/application_controller.rb +2 -1
- data/app/controllers/users_controller.rb +5 -1
- data/app/helpers/application_helper.rb +6 -4
- data/app/helpers/avatar_helper.rb +9 -0
- data/app/helpers/discussions_helper.rb +2 -2
- data/app/helpers/{locale_helper.rb → globals_helper.rb} +6 -2
- data/app/helpers/profile_helper.rb +5 -0
- data/app/mailers/user_mailer.rb +24 -11
- data/app/views/book/show.html.erb +1 -1
- data/app/views/exercises/show.html.erb +3 -0
- data/app/views/layouts/_main.html.erb +1 -2
- data/app/views/layouts/_progress.html.erb +1 -1
- data/app/views/layouts/_progress_bar.html.erb +7 -1
- data/app/views/layouts/_runner_assets.html.erb +1 -2
- data/app/views/layouts/application.html.erb +2 -2
- data/app/views/layouts/modals/_avatar_picker.html.erb +16 -0
- data/app/views/users/_avatar_list.html.erb +11 -0
- data/app/views/users/_edit_user_form.html.erb +22 -0
- data/app/views/users/_user_form.html.erb +21 -8
- data/app/views/users/edit.html.erb +5 -0
- data/app/views/users/show.html.erb +0 -4
- data/config/routes.rb +1 -1
- data/lib/mumuki/laboratory/controllers.rb +1 -0
- data/lib/mumuki/laboratory/controllers/incognito_mode.rb +28 -0
- data/lib/mumuki/laboratory/locales/datetime.es.yml +14 -14
- data/lib/mumuki/laboratory/locales/en.yml +12 -4
- data/lib/mumuki/laboratory/locales/es.yml +12 -4
- data/lib/mumuki/laboratory/locales/pt.yml +10 -2
- data/lib/mumuki/laboratory/version.rb +1 -1
- data/spec/dummy/db/schema.rb +13 -1
- data/spec/features/chapter_spec.rb +17 -0
- data/spec/features/exercise_flow_spec.rb +54 -6
- data/spec/features/home_public_flow_spec.rb +16 -0
- data/spec/helpers/avatar_helper_spec.rb +26 -0
- data/spec/javascripts/editors-spec.js +54 -0
- data/spec/javascripts/events-spec.js +33 -0
- data/spec/javascripts/exercise-spec.js +41 -0
- data/spec/javascripts/global-spec.js +6 -0
- data/spec/javascripts/spec-helper.js +4 -0
- data/spec/javascripts/submissions-store-spec.js +44 -0
- data/spec/javascripts/sync-mode-spec.js +15 -0
- data/spec/mailers/user_mailer_spec.rb +23 -3
- data/spec/teaspoon_env.rb +8 -2
- data/vendor/assets/javascripts/codemirror-modes/gobstones.js +3 -3
- metadata +38 -11
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_follow_us.scss +0 -16
- data/app/helpers/version_helper.rb +0 -5
@@ -7,6 +7,7 @@ pt:
|
|
7
7
|
actions: Ações
|
8
8
|
activity: Atividade
|
9
9
|
actual_state: Tablero obtido
|
10
|
+
age: Idade
|
10
11
|
all: Todos
|
11
12
|
and: e
|
12
13
|
appendix: Apêndice
|
@@ -29,10 +30,12 @@ pt:
|
|
29
30
|
bibliotheca_ui: Biblioteca
|
30
31
|
birthdate: Fecha de nacimiento
|
31
32
|
blocked_forum_explanation: Você não tem permissão para ver este conteúdo. <br> Você está no meio de um exame agora?
|
33
|
+
cancel: Cancelar
|
32
34
|
chapter: Capítulo
|
33
35
|
chapters: Capítulos
|
34
36
|
chapter_finished_html: Você terminou %{chapter}! Parabéns!
|
35
37
|
chapter_number: Capítulo %{number}
|
38
|
+
choose_your_avatar: Escolha seu avatar
|
36
39
|
classroom_ui: Sala de aula
|
37
40
|
clear_console: Reiniciar o console
|
38
41
|
closed: Fechado
|
@@ -68,6 +71,7 @@ pt:
|
|
68
71
|
discussions: Consultas
|
69
72
|
download: Faça o download do que você fez
|
70
73
|
edit: Editar
|
74
|
+
edit_profile: Editar perfil
|
71
75
|
editor_placeholder: ... Escreva sua solução aqui ...
|
72
76
|
email: E-mail
|
73
77
|
error_description: Opa! <br> Isto é o que é conhecido como <span class = "error-link"> %{error} </ span>.
|
@@ -171,6 +175,7 @@ pt:
|
|
171
175
|
not_in_any_organizations: Parece que você ainda não está em nenhuma organização!
|
172
176
|
notify_problem_with_exercise: Relatar um erro
|
173
177
|
office: Secretariado
|
178
|
+
only_landscape_support: Por favor, gire seu tablet ou celular para realizar exercícios
|
174
179
|
opened: Aberto
|
175
180
|
opened_count: '%{count} aberto'
|
176
181
|
organizations: Organizações
|
@@ -194,6 +199,7 @@ pt:
|
|
194
199
|
processing_your_solution: Estamos processando sua solução
|
195
200
|
profile: Perfil
|
196
201
|
profile_of: Perfil de %{username}
|
202
|
+
programming_since: Sou programador
|
197
203
|
progress: Progresso
|
198
204
|
read: Ler
|
199
205
|
read_messages: Ver mensagens
|
@@ -240,6 +246,7 @@ pt:
|
|
240
246
|
submissions_for: Soluções para %{exercise}
|
241
247
|
subscribe: se inscrever
|
242
248
|
tag: Etiquetas
|
249
|
+
task: Tarefa
|
243
250
|
teacher_info: Informação para professores
|
244
251
|
tell_us_how: Conte-nos como isso aconteceu com você!
|
245
252
|
tell_us_if_our_error: Se você acha que é nosso erro, %{issues}
|
@@ -265,8 +272,9 @@ pt:
|
|
265
272
|
username: Nome de usuário
|
266
273
|
view_details: Ver detalhes
|
267
274
|
want_permissions: O próximo usuário requer permissões
|
275
|
+
welcome: Convidamos você a {name}!
|
268
276
|
working: Processamento
|
269
277
|
wrong_answer: A resposta não é correta
|
278
|
+
years: anos
|
270
279
|
you_must_sign_in_before_submitting: Você deve fazer o login antes de começar a enviar suas soluções
|
271
|
-
|
272
|
-
only_landscape_support: Por favor, gire seu tablet ou celular para realizar exercícios
|
280
|
+
your_new_organization: sua nova organização
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
#
|
11
11
|
# It's strongly recommended that you check this file into your version control system.
|
12
12
|
|
13
|
-
ActiveRecord::Schema.define(version:
|
13
|
+
ActiveRecord::Schema.define(version: 20200804191643) do
|
14
14
|
|
15
15
|
# These are extensions that must be enabled in order to support this database
|
16
16
|
enable_extension "plpgsql"
|
@@ -44,6 +44,7 @@ ActiveRecord::Schema.define(version: 20200731081757) do
|
|
44
44
|
t.bigint "organization_id"
|
45
45
|
t.datetime "submitted_at"
|
46
46
|
t.bigint "parent_id"
|
47
|
+
t.integer "top_submission_status"
|
47
48
|
t.index ["exercise_id"], name: "index_assignments_on_exercise_id"
|
48
49
|
t.index ["organization_id"], name: "index_assignments_on_organization_id"
|
49
50
|
t.index ["parent_id"], name: "index_assignments_on_parent_id"
|
@@ -54,6 +55,7 @@ ActiveRecord::Schema.define(version: 20200731081757) do
|
|
54
55
|
create_table "avatars", force: :cascade do |t|
|
55
56
|
t.string "image_url"
|
56
57
|
t.string "description"
|
58
|
+
t.integer "target_audience", default: 0
|
57
59
|
end
|
58
60
|
|
59
61
|
create_table "books", id: :serial, force: :cascade do |t|
|
@@ -309,6 +311,8 @@ ActiveRecord::Schema.define(version: 20200731081757) do
|
|
309
311
|
t.text "theme", default: "{}", null: false
|
310
312
|
t.text "profile", default: "{}", null: false
|
311
313
|
t.integer "progressive_display_lookahead"
|
314
|
+
t.integer "target_audience", default: 0
|
315
|
+
t.boolean "incognito_mode_enabled"
|
312
316
|
t.index ["book_id"], name: "index_organizations_on_book_id"
|
313
317
|
t.index ["name"], name: "index_organizations_on_name", unique: true
|
314
318
|
end
|
@@ -363,6 +367,14 @@ ActiveRecord::Schema.define(version: 20200731081757) do
|
|
363
367
|
t.index ["parent_item_type", "parent_item_id"], name: "index_usages_on_parent_item_type_and_parent_item_id"
|
364
368
|
end
|
365
369
|
|
370
|
+
create_table "user_stats", force: :cascade do |t|
|
371
|
+
t.integer "exp", default: 0
|
372
|
+
t.bigint "user_id"
|
373
|
+
t.bigint "organization_id"
|
374
|
+
t.index ["organization_id"], name: "index_user_stats_on_organization_id"
|
375
|
+
t.index ["user_id"], name: "index_user_stats_on_user_id"
|
376
|
+
end
|
377
|
+
|
366
378
|
create_table "users", id: :serial, force: :cascade do |t|
|
367
379
|
t.string "provider"
|
368
380
|
t.string "social_id"
|
@@ -50,4 +50,21 @@ feature 'Chapters flow', organization_workspace: :test do
|
|
50
50
|
expect(page).to have_text('endofunctors')
|
51
51
|
end
|
52
52
|
end
|
53
|
+
|
54
|
+
context 'incognito user' do
|
55
|
+
before { Organization.current.update! incognito_mode_enabled: true }
|
56
|
+
scenario 'show chapter, no appendix' do
|
57
|
+
visit "/chapters/#{chapter.id}"
|
58
|
+
|
59
|
+
expect(page).to have_text('Functional Programming')
|
60
|
+
expect(page).to have_text('The Basic Values')
|
61
|
+
|
62
|
+
expect(page).to have_text('Monads and Functors')
|
63
|
+
expect(page).to have_text('The Maybe Functor')
|
64
|
+
|
65
|
+
expect(page).to_not have_text('Appendix')
|
66
|
+
|
67
|
+
expect(page).to have_text('Sign in')
|
68
|
+
end
|
69
|
+
end
|
53
70
|
end
|
@@ -9,12 +9,14 @@ feature 'Exercise Flow', organization_workspace: :test do
|
|
9
9
|
let(:problem_1) { build(:problem, name: 'Succ1', description: 'Description of Succ1', layout: :input_right, hint: 'lala') }
|
10
10
|
let(:problem_2) { build(:problem, name: 'Succ2', description: 'Description of Succ2', layout: :input_right, editor: :hidden, language: gobstones) }
|
11
11
|
let(:problem_3) { build(:problem, name: 'Succ3', description: 'Description of Succ3', layout: :input_right, editor: :upload, hint: 'lele') }
|
12
|
-
let(:
|
12
|
+
let(:with_settings_and_extra) do
|
13
|
+
build(:problem, name: 'Succ4', description: 'Description of Succ4', layout: :input_bottom, settings: {foo: 1}, extra: 'x = 2')
|
14
|
+
end
|
13
15
|
let(:problem_5) { build(:problem, name: 'Succ5', description: 'Description of Succ5', layout: :input_right, editor: :upload, hint: 'lele', language: gobstones) }
|
14
16
|
let(:problem_6) { build(:problem, name: 'Succ6', description: 'Description of Succ6', layout: :input_right, editor: :hidden, language: haskell) }
|
15
17
|
let(:problem_7) { build(:problem, name: 'Succ7', description: 'Description of Succ7', editor: :single_choice, choices: [{value: 'some choice', checked: true}]) }
|
16
|
-
let(:playground_1) { build(:playground, name: 'Succ5', description: 'Description of Succ4', layout: :
|
17
|
-
let(:playground_2) { build(:playground, name: 'Succ6', description: 'Description of Succ4', layout: :
|
18
|
+
let(:playground_1) { build(:playground, name: 'Succ5', description: 'Description of Succ4', layout: :input_bottom) }
|
19
|
+
let(:playground_2) { build(:playground, name: 'Succ6', description: 'Description of Succ4', layout: :input_bottom, extra: 'x = 4') }
|
18
20
|
let!(:reading) { build(:reading, name: 'Reading about Succ', description: 'Lets understand succ history') }
|
19
21
|
let!(:exercise_not_in_path) { create :exercise }
|
20
22
|
let(:kids_problem) { build(:problem, name: 'Kids prob', description: 'Description of kids prob', layout: :input_primary, hint: 'lele', language: gobstones) }
|
@@ -22,7 +24,7 @@ feature 'Exercise Flow', organization_workspace: :test do
|
|
22
24
|
let!(:chapter) {
|
23
25
|
create(:chapter, name: 'Functional Programming', lessons: [
|
24
26
|
create(:lesson, name: 'getting-started', description: 'An awesome guide', language: haskell, exercises: [
|
25
|
-
problem_1, problem_2, problem_3,
|
27
|
+
problem_1, problem_2, problem_3, with_settings_and_extra, reading, problem_5, problem_6, problem_7, playground_1, playground_2, kids_problem
|
26
28
|
])
|
27
29
|
]) }
|
28
30
|
|
@@ -129,6 +131,12 @@ feature 'Exercise Flow', organization_workspace: :test do
|
|
129
131
|
expect(page).to have_text('Solution')
|
130
132
|
expect(page).to have_text('need a hint?')
|
131
133
|
expect(page).to_not have_selector('.upload')
|
134
|
+
|
135
|
+
expect(page).to have_selector('#mu-exercise-id', )
|
136
|
+
expect(page).to have_selector('#mu-exercise-layout')
|
137
|
+
|
138
|
+
expect(page.find("#mu-exercise-id")['value']).to eq(problem_1.id.to_s)
|
139
|
+
expect(page.find("#mu-exercise-layout")['value']).to eq('input_right')
|
132
140
|
end
|
133
141
|
|
134
142
|
scenario 'visit exercise by id, hidden layout, no hint, not queriable language' do
|
@@ -142,6 +150,9 @@ feature 'Exercise Flow', organization_workspace: :test do
|
|
142
150
|
expect(page).to_not have_text('Solution')
|
143
151
|
expect(page).to_not have_text('need a hint?')
|
144
152
|
expect(page).to_not have_selector('.upload')
|
153
|
+
|
154
|
+
expect(page.find("#mu-exercise-id")['value']).to eq(problem_2.id.to_s)
|
155
|
+
expect(page.find("#mu-exercise-layout")['value']).to eq('input_right')
|
145
156
|
end
|
146
157
|
|
147
158
|
scenario 'visit exercise by id, hidden layout, no hint, queriable language' do
|
@@ -152,6 +163,9 @@ feature 'Exercise Flow', organization_workspace: :test do
|
|
152
163
|
expect(page).to_not have_text('Solution')
|
153
164
|
expect(page).to_not have_text('need a hint?')
|
154
165
|
expect(page).to_not have_selector('.upload')
|
166
|
+
|
167
|
+
expect(page.find("#mu-exercise-id")['value']).to eq(problem_6.id.to_s)
|
168
|
+
expect(page.find("#mu-exercise-layout")['value']).to eq('input_right')
|
155
169
|
end
|
156
170
|
|
157
171
|
|
@@ -163,6 +177,9 @@ feature 'Exercise Flow', organization_workspace: :test do
|
|
163
177
|
expect(page).to have_text('Solution')
|
164
178
|
expect(page).to have_text('need a hint?')
|
165
179
|
expect(page).to have_selector('.upload')
|
180
|
+
|
181
|
+
expect(page.find("#mu-exercise-id")['value']).to eq(problem_3.id.to_s)
|
182
|
+
expect(page.find("#mu-exercise-layout")['value']).to eq('input_right')
|
166
183
|
end
|
167
184
|
|
168
185
|
scenario 'visit exercise by id, upload layout, not queriable language' do
|
@@ -174,10 +191,13 @@ feature 'Exercise Flow', organization_workspace: :test do
|
|
174
191
|
expect(page).to have_selector('.upload')
|
175
192
|
expect(problem_5.language.extension).to eq('gbs')
|
176
193
|
expect(page.find("//div[@class = 'form-group']/input")['accept']).to eq(".gbs")
|
194
|
+
|
195
|
+
expect(page.find("#mu-exercise-id")['value']).to eq(problem_5.id.to_s)
|
196
|
+
expect(page.find("#mu-exercise-layout")['value']).to eq('input_right')
|
177
197
|
end
|
178
198
|
|
179
|
-
scenario 'visit exercise by id, input_bottom layout, extra, no hint' do
|
180
|
-
visit "/exercises/#{
|
199
|
+
scenario 'visit exercise by id, input_bottom layout, extra, setting, no hint' do
|
200
|
+
visit "/exercises/#{with_settings_and_extra.id}"
|
181
201
|
|
182
202
|
expect(page).to have_text('Succ4')
|
183
203
|
expect(page).to have_text('x = 2')
|
@@ -185,6 +205,10 @@ feature 'Exercise Flow', organization_workspace: :test do
|
|
185
205
|
expect(page).to have_text('Solution')
|
186
206
|
expect(page).to_not have_text('need a hint?')
|
187
207
|
expect(page).to_not have_selector('.upload')
|
208
|
+
|
209
|
+
expect(page.find("#mu-exercise-id")['value']).to eq(with_settings_and_extra.id.to_s)
|
210
|
+
expect(page.find("#mu-exercise-layout")['value']).to eq('input_bottom')
|
211
|
+
expect(page.find("#mu-exercise-settings")['value']).to eq('{"foo":1}')
|
188
212
|
end
|
189
213
|
|
190
214
|
scenario 'visit playground by id, no extra, no hint' do
|
@@ -195,6 +219,9 @@ feature 'Exercise Flow', organization_workspace: :test do
|
|
195
219
|
expect(page).to_not have_text('Solution')
|
196
220
|
expect(page).to_not have_text('need a hint?')
|
197
221
|
expect(page).to_not have_selector('.upload')
|
222
|
+
|
223
|
+
expect(page.find("#mu-exercise-id")['value']).to eq(playground_1.id.to_s)
|
224
|
+
expect(page.find("#mu-exercise-layout")['value']).to eq('input_bottom')
|
198
225
|
end
|
199
226
|
|
200
227
|
scenario 'visit playground by id, with extra, no hint' do
|
@@ -206,6 +233,9 @@ feature 'Exercise Flow', organization_workspace: :test do
|
|
206
233
|
expect(page).to_not have_text('need a hint?')
|
207
234
|
expect(page).to have_text('x = 4')
|
208
235
|
expect(page).to_not have_selector('.upload')
|
236
|
+
|
237
|
+
expect(page.find("#mu-exercise-id")['value']).to eq(playground_2.id.to_s)
|
238
|
+
expect(page.find("#mu-exercise-layout")['value']).to eq('input_bottom')
|
209
239
|
end
|
210
240
|
|
211
241
|
scenario 'visit inner reading by id' do
|
@@ -218,6 +248,9 @@ feature 'Exercise Flow', organization_workspace: :test do
|
|
218
248
|
expect(page).to_not have_text('Solution')
|
219
249
|
expect(page).to_not have_text('need a hint?')
|
220
250
|
expect(page).to_not have_selector('.upload')
|
251
|
+
|
252
|
+
expect(page.find("#mu-exercise-id")['value']).to eq(reading.id.to_s)
|
253
|
+
expect(page.find("#mu-exercise-layout")['value']).to eq('input_bottom')
|
221
254
|
end
|
222
255
|
|
223
256
|
scenario 'visit solved choices exercise' do
|
@@ -246,4 +279,19 @@ feature 'Exercise Flow', organization_workspace: :test do
|
|
246
279
|
expect(page).to have_xpath("//a[@title='Edit']")
|
247
280
|
end
|
248
281
|
end
|
282
|
+
|
283
|
+
context 'incognito user' do
|
284
|
+
before { Organization.current.update! incognito_mode_enabled: true }
|
285
|
+
|
286
|
+
scenario 'visit exercise transparently' do
|
287
|
+
visit "/exercises/#{problem_1.transparent_id}"
|
288
|
+
|
289
|
+
expect(page).to have_text('Succ1')
|
290
|
+
expect(page).to have_text('Console')
|
291
|
+
expect(page).to have_text('need a hint?')
|
292
|
+
expect(page).to have_text('Description of Succ1')
|
293
|
+
|
294
|
+
expect(page).to have_text('Sign in')
|
295
|
+
end
|
296
|
+
end
|
249
297
|
end
|
@@ -91,4 +91,20 @@ feature 'public org', organization_workspace: :test do
|
|
91
91
|
expect(user.reload.last_organization).to eq current_organization
|
92
92
|
end
|
93
93
|
end
|
94
|
+
|
95
|
+
context 'incognito user' do
|
96
|
+
before { current_organization.update! incognito_mode_enabled: true }
|
97
|
+
scenario 'from inside' do
|
98
|
+
Capybara.current_session.driver.header 'Referer', 'http://google.com'
|
99
|
+
|
100
|
+
visit '/'
|
101
|
+
|
102
|
+
expect(page).to have_text('ム mumuki')
|
103
|
+
expect(page).to have_text('First Steps')
|
104
|
+
expect(page).to have_selector('.chapter', text: 'Functional Programming')
|
105
|
+
expect(page).to have_text(current_organization.book.name)
|
106
|
+
|
107
|
+
expect(page).to have_text('Sign in')
|
108
|
+
end
|
109
|
+
end
|
94
110
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe AvatarHelper, organization_workspace: :test do
|
4
|
+
helper AvatarHelper
|
5
|
+
|
6
|
+
let(:user) { create(:user, avatar: kids_avatars.last) }
|
7
|
+
|
8
|
+
let(:kids_avatars) { create_list(:avatar, 4, target_audience: :kids) }
|
9
|
+
let!(:grown_ups_avatars) { create_list(:avatar, 3, target_audience: :grown_ups) }
|
10
|
+
|
11
|
+
let!(:kids_organization) { create(:organization, target_audience: :kids) }
|
12
|
+
let!(:grown_ups_organization) { create(:organization, target_audience: :grown_ups, name: 'for_grown_ups') }
|
13
|
+
|
14
|
+
describe 'avatars_for' do
|
15
|
+
context 'with avatar in same target audience as organization' do
|
16
|
+
before { kids_organization.switch! }
|
17
|
+
it { expect(avatars_for(user)).to eq kids_avatars }
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'with avatar in different target audience as organization' do
|
21
|
+
before { grown_ups_organization.switch! }
|
22
|
+
it { expect(avatars_for(user)).to eq grown_ups_avatars + [user.avatar] }
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
describe('editors', () => {
|
2
|
+
|
3
|
+
beforeEach(() => {
|
4
|
+
mumuki.CustomEditor.clearSources()
|
5
|
+
})
|
6
|
+
|
7
|
+
it('has initially no sources', () => {
|
8
|
+
expect(mumuki.CustomEditor.hasSources).toBe(false)
|
9
|
+
});
|
10
|
+
|
11
|
+
it('can add a custom source', () => {
|
12
|
+
mumuki.editors.addCustomSource({
|
13
|
+
getContent() {
|
14
|
+
return { name: "solution[content]", value: 'the value' } ;
|
15
|
+
}
|
16
|
+
});
|
17
|
+
|
18
|
+
expect(mumuki.CustomEditor.hasSources).toBe(true);
|
19
|
+
expect(mumuki.CustomEditor.getContents()[0].value).toEqual('the value');
|
20
|
+
expect(mumuki.CustomEditor.getContents()[0].name).toEqual('solution[content]');
|
21
|
+
});
|
22
|
+
|
23
|
+
it('reads the custom sources if present, ignoring the form', () => {
|
24
|
+
$('body').html(`
|
25
|
+
<form role="form" class="new_solution">
|
26
|
+
<div class="field form-group editor-code">
|
27
|
+
<textarea class="form-control editor" name="solution[content]" id="solution_content">the standard solution</textarea>
|
28
|
+
</div>
|
29
|
+
</form>`)
|
30
|
+
|
31
|
+
mumuki.editors.addCustomSource({
|
32
|
+
getContent() {
|
33
|
+
return { name: "solution[content]", value: 'the custom solution' } ;
|
34
|
+
}
|
35
|
+
});
|
36
|
+
|
37
|
+
expect(mumuki.editors.getSubmission()).toEqual({"solution[content]":"the custom solution"});
|
38
|
+
});
|
39
|
+
|
40
|
+
it('reads the form if no sources', () => {
|
41
|
+
$('body').html(`
|
42
|
+
<form role="form" class="new_solution">
|
43
|
+
<div class="field form-group editor-code">
|
44
|
+
<textarea class="form-control editor" name="solution[content]" id="solution_content">the solution</textarea>
|
45
|
+
</div>
|
46
|
+
</form>`)
|
47
|
+
expect(mumuki.editors.getSubmission()).toEqual({"solution[content]":"the solution"});
|
48
|
+
});
|
49
|
+
|
50
|
+
it('produces empty submission if no form nor sources', () => {
|
51
|
+
$('body').html(``);
|
52
|
+
expect(mumuki.editors.getSubmission()).toEqual({});
|
53
|
+
});
|
54
|
+
})
|
@@ -0,0 +1,33 @@
|
|
1
|
+
describe('events', () => {
|
2
|
+
beforeEach(() => {
|
3
|
+
mumuki.events.clear('foo');
|
4
|
+
});
|
5
|
+
|
6
|
+
it('is not called when it is not fired', () => {
|
7
|
+
mumuki.events.on('foo', (e) => {
|
8
|
+
fail(`should not be called, but got ${JSON.stringify(e)}`);
|
9
|
+
})
|
10
|
+
})
|
11
|
+
|
12
|
+
it('is not called when it is fired but not enabled', () => {
|
13
|
+
let fired = false;
|
14
|
+
mumuki.events.on('foo', (e) => {
|
15
|
+
fail(`should not be called, but got ${JSON.stringify(e)}`);
|
16
|
+
fired = true;
|
17
|
+
})
|
18
|
+
mumuki.events.fire('foo', 42);
|
19
|
+
expect(fired).toBe(false);
|
20
|
+
})
|
21
|
+
|
22
|
+
it('is called when it is fired and enabled', () => {
|
23
|
+
let fired = false;
|
24
|
+
mumuki.events.enable('foo');
|
25
|
+
mumuki.events.on('foo', (event) => {
|
26
|
+
expect(event).toEqual(42);
|
27
|
+
fired = true;
|
28
|
+
})
|
29
|
+
|
30
|
+
mumuki.events.fire('foo', 42);
|
31
|
+
expect(fired).toBe(true);
|
32
|
+
})
|
33
|
+
})
|
@@ -0,0 +1,41 @@
|
|
1
|
+
describe('exercise', () => {
|
2
|
+
|
3
|
+
it('current exercise information is available when present', () => {
|
4
|
+
$('body').html(`
|
5
|
+
<input type="hidden" name="mu-exercise-id" id="mu-exercise-id" value="3361" />
|
6
|
+
<input type="hidden" name="mu-exercise-layout" id="mu-exercise-layout" value="input_right" />
|
7
|
+
<input type="hidden" name="mu-exercise-settings" id="mu-exercise-settings" value="{}" />`)
|
8
|
+
|
9
|
+
mumuki.exercise.load();
|
10
|
+
|
11
|
+
expect(mumuki.exercise.id).toBe(3361);
|
12
|
+
expect(mumuki.exercise.layout).toBe('input_right');
|
13
|
+
expect(mumuki.exercise.settings).toEqual({});
|
14
|
+
expect(mumuki.exercise.current).not.toBe(null);
|
15
|
+
})
|
16
|
+
|
17
|
+
it('current exercise information is available when present and settings are not empty', () => {
|
18
|
+
$('body').html(`
|
19
|
+
<input type="hidden" name="mu-exercise-id" id="mu-exercise-id" value="3361" />
|
20
|
+
<input type="hidden" name="mu-exercise-layout" id="mu-exercise-layout" value="input_right" />
|
21
|
+
<input type="hidden" name="mu-exercise-settings" id="mu-exercise-settings" value="{"game_framework":true}" />`)
|
22
|
+
|
23
|
+
mumuki.exercise.load();
|
24
|
+
|
25
|
+
expect(mumuki.exercise.id).toBe(3361);
|
26
|
+
expect(mumuki.exercise.layout).toBe('input_right');
|
27
|
+
expect(mumuki.exercise.settings.game_framework).toBe(true);
|
28
|
+
expect(mumuki.exercise.current).not.toBe(null);
|
29
|
+
})
|
30
|
+
|
31
|
+
it('current exercise information is available when not present', () => {
|
32
|
+
$('body').html(``)
|
33
|
+
|
34
|
+
mumuki.exercise.load();
|
35
|
+
|
36
|
+
expect(mumuki.exercise.id).toBe(null);
|
37
|
+
expect(mumuki.exercise.layout).toBe(null);
|
38
|
+
expect(mumuki.exercise.settings).toBe(null);
|
39
|
+
expect(mumuki.exercise.current).toBe(null);
|
40
|
+
})
|
41
|
+
})
|