File tree 4 files chan
8000
ged +73
-3
lines changed
lib/active_admin/views/components
spec/unit/views/components 4 files changed +73
-3
lines changed Original file line number Diff line number Diff line change
1
+ Feature : Show - Columns
2
+
3
+ Columns in show page
4
+
5
+ Background :
6
+ Given a post with the title "Hello World" written by "Jane Doe" exists
7
+
8
+ Scenario :
9
+ Given a show configuration of:
10
+ """
11
+ ActiveAdmin.register Post do
12
+
13
+ show do
14
+ columns do
15
+ end
16
+ end
17
+
18
+ end
19
+ """
20
+ Then I should see a columns container
21
+ And I should see 0 column
22
+
23
+ Scenario :
24
+ Given a show configuration of:
25
+ """
26
+ ActiveAdmin.register Post do
27
+
28
+ show do
29
+ columns do
30
+ column do
31
+ end
32
+ column do
33
+ end
34
+ end
35
+ end
36
+
37
+ end
38
+ """
39
+ Then I should see a columns container
40
+ And I should see 2 columns
Original file line number Diff line number Diff line change
1
+ Then /^I should see a columns container$/ do
2
+ expect ( page ) . to have_css '.columns'
3
+ end
4
+
5
+ Then /^I should see (a|\d +) columns?$/ do |count |
6
+ count = count == 'a' ? 1 : count . to_i
7
+ expect ( page ) . to have_css '.column' , count : count
8
+ end
Original file line number Diff line number Diff line change @@ -93,19 +93,24 @@ def calculate_columns!
93
93
all_margins_width = margin_size * ( span_count - 1 )
94
94
column_width = ( 100.00 - all_margins_width ) / span_count
95
95
96
- children . each_with_index do |col , i |
96
+ columns . each_with_index do |column , i |
97
97
is_last_column = i == ( columns_count - 1 )
98
- col . set_column_styles ( column_width , margin_size , is_last_column )
98
+ column . set_column_styles ( column_width , margin_size , is_last_column )
99
99
end
100
100
end
101
101
102
102
def columns_span_count
103
103
count = 0
104
- children . each { |column | count += column . span_size }
104
+ columns . each do |column |
105
+ count += column . span_size
106
+ end
105
107
106
108
count
107
109
end
108
110
111
+ def columns
112
+ children . select { |child | child . is_a? ( Column ) }
113
+ end
109
114
end
110
115
111
116
class Column < ActiveAdmin ::Component
Original file line number Diff line number Diff line change 2
2
3
3
describe ActiveAdmin ::Views ::Columns do
4
4
5
+ describe "Rendering zero columns" do
6
+ let ( :cols ) do
7
+ render_arbre_component do
8
+ columns do
9
+ end
10
+ end
11
+ end
12
+
13
+ it "should have the class .columns" do
14
+ expect ( cols . class_list ) . to include ( "columns" )
15
+ end
16
+
17
+ it "should have one column" do
18
+ expect ( cols . children . first . class_list ) . not_to include ( "column" )
19
+ end
20
+ end
21
+
5
22
describe "Rendering one column" do
6
23
let ( :cols ) do
7
24
render_arbre_component do
You can’t perform that action at this time.
0 commit comments