1
1
require 'spec_helper'
2
2
3
- feature 'Article composing' do
3
+ feature 'Article localization features' , :js do
4
4
5
5
given! ( :current_user ) { create ( :user ) }
6
6
7
7
before do
8
8
login_user ( current_user )
9
9
end
10
10
11
- scenario 'Create an article' , :js do
11
+ scenario 'Create an article' do
12
12
13
13
within ( main_menubar ) { click_link 'Articles' }
14
14
within ( action_bar ) { click_link 'New Article' }
21
21
end
22
22
23
23
page . should have_content 'Article was successfully created.'
24
- # Retrieve article from database
24
+
25
+ # Retrieve created article from database
25
26
article = Article . first
26
27
page . should have_content article . title
27
28
page . should have_content article . body
28
29
end
29
30
31
+ context 'Viewing article translations' do
32
+
33
+ given! ( :article ) { create ( :localized_article ) }
34
+
35
+ before do
36
+ # Load article page
37
+ ensure_on ( admin_article_path ( article ) )
38
+ end
39
+
40
+ # See spec/dummy/app/admin/articles.rb
41
+ scenario 'Viewing a translated article' do
42
+
43
+ # First row shows default locale with label title
44
+ within first_table_row do
45
+ page . should have_css 'th' , text : 'TITLE'
46
+ page . should have_css 'span.field-translation' , text : article . title
47
+ end
48
+ # Second row shows italian title by default
49
+ within second_table_row do
50
+ page . should have_css 'th' , text : 'ITALIAN TITLE'
51
+ page . should have_css 'span.field-translation' , text : article . translation_for ( :it ) . title
52
+ end
53
+
54
+ end
55
+
56
+ scenario 'Switch inline translations' do
57
+
58
+ # First row shows default locale with label title
59
+ within first_table_row do
60
+ page . should have_css 'th' , text : 'TITLE'
61
+ page . should have_css 'span.field-translation' , text : article . title
62
+ flag_link ( :it ) . click # change shown translation
63
+ page . should have_css 'span.field-translation' , text : article . translation_for ( :it ) . title
64
+ end
65
+
66
+ end
67
+
68
+ end
69
+
30
70
end
0 commit comments