authorized_rails_scaffolds 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/authorized_rails_scaffolds/helper.rb +6 -0
- data/lib/authorized_rails_scaffolds/version.rb +1 -1
- data/lib/generators/authorized_rails_scaffolds/install_macros/templates/devise_can_can/USAGE +1 -1
- data/lib/generators/authorized_rails_scaffolds/install_macros/templates/devise_can_can/controller_macros.rb +34 -15
- data/lib/generators/authorized_rails_scaffolds/install_templates/templates/scaffold/controller.rb +2 -2
- data/lib/generators/authorized_rails_scaffolds/install_templates/templates/spec/controller_spec.rb +292 -246
- data/lib/generators/authorized_rails_scaffolds/install_templates/templates/spec/edit_spec.rb +52 -43
- data/lib/generators/authorized_rails_scaffolds/install_templates/templates/spec/index_spec.rb +101 -95
- data/lib/generators/authorized_rails_scaffolds/install_templates/templates/spec/new_spec.rb +51 -43
- data/lib/generators/authorized_rails_scaffolds/install_templates/templates/spec/show_spec.rb +49 -41
- metadata +8 -8
data/lib/generators/authorized_rails_scaffolds/install_templates/templates/spec/edit_spec.rb
CHANGED
@@ -18,10 +18,11 @@ datetime_attributes = t_helper.datetime_attributes
|
|
18
18
|
|
19
19
|
-%>
|
20
20
|
describe "<%= ns_table_name %>/edit" do
|
21
|
+
|
21
22
|
before(:each) do
|
22
|
-
|
23
|
+
<%- AuthorizedRailsScaffolds.parent_models.each do |model| -%>
|
23
24
|
@<%= model.underscore %> = assign(:<%= model.underscore %>, FactoryGirl.build_stubbed(:<%= model.underscore %>))
|
24
|
-
|
25
|
+
<%- end -%>
|
25
26
|
@<%= var_name %> = assign(:<%= var_name %>, FactoryGirl.build_stubbed(:<%= var_name %><%= output_attributes.empty? ? '))' : ',' %>
|
26
27
|
<% output_attributes.each_with_index do |attribute, attribute_index| -%>
|
27
28
|
:<%= attribute.name %> => <%= t_helper.factory_attribute_value attribute.type, value_for(attribute) %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
|
@@ -29,79 +30,87 @@ describe "<%= ns_table_name %>/edit" do
|
|
29
30
|
<%= output_attributes.empty? ? "" : " ))\n" -%>
|
30
31
|
end
|
31
32
|
|
32
|
-
|
33
|
-
|
33
|
+
context do # Within default nesting
|
34
|
+
before(:each) do
|
35
|
+
<%- AuthorizedRailsScaffolds.parent_models.each do |model| -%>
|
36
|
+
assign(:<%= model.underscore %>, @<%= model.underscore %>)
|
37
|
+
<%- end -%>
|
38
|
+
end
|
39
|
+
|
40
|
+
it "renders the edit <%= var_name %> form" do
|
41
|
+
render
|
34
42
|
|
35
43
|
<% if webrat? -%>
|
36
|
-
|
44
|
+
rendered.should have_selector("form", :action => <%= t_helper.controller_show_route "@#{var_name}" %>, :method => "post") do |form|
|
37
45
|
<% for attribute in standard_attributes -%>
|
38
46
|
<%- if attribute.type == :references -%>
|
39
|
-
|
47
|
+
form.should have_selector("select#<%= var_name %>_<%= attribute.name %>_id", :name => "<%= var_name %>[<%= attribute.name %>_id]")
|
40
48
|
<%- else -%>
|
41
|
-
|
49
|
+
form.should have_selector("<%= attribute.input_type -%>#<%= var_name %>_<%= attribute.name %>", :name => "<%= var_name %>[<%= attribute.name %>]")
|
42
50
|
<%- end -%>
|
43
51
|
<% end -%>
|
44
|
-
|
52
|
+
end
|
45
53
|
<% else -%>
|
46
|
-
|
47
|
-
|
54
|
+
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
55
|
+
assert_select "form[action=?][method=?]", <%= t_helper.controller_show_route "@#{var_name}" %>, "post" do
|
48
56
|
<% for attribute in standard_attributes -%>
|
49
57
|
<%- if attribute.type == :references -%>
|
50
|
-
|
58
|
+
assert_select "select#<%= var_name %>_<%= attribute.name %>_id[name=?]", "<%= var_name %>[<%= attribute.name %>_id]"
|
51
59
|
<%- else -%>
|
52
|
-
|
60
|
+
assert_select "<%= attribute.input_type -%>#<%= var_name %>_<%= attribute.name %>[name=?]", "<%= var_name %>[<%= attribute.name %>]"
|
53
61
|
<%- end -%>
|
54
62
|
<% end -%>
|
55
|
-
|
63
|
+
end
|
56
64
|
<% end -%>
|
57
|
-
|
65
|
+
end
|
58
66
|
|
59
67
|
<% if datetime_attributes.any? -%>
|
60
|
-
|
61
|
-
|
68
|
+
it "renders all date/time form elements" do
|
69
|
+
render
|
62
70
|
|
63
71
|
<% if webrat? -%>
|
64
|
-
|
72
|
+
rendered.should have_selector("form", :action => <%= t_helper.controller_show_route "@#{var_name}" %>, :method => "post") do |form|
|
65
73
|
<% for attribute in datetime_attributes -%>
|
66
74
|
<%- if [:date, :datetime].include? attribute.type -%>
|
67
|
-
|
68
|
-
|
69
|
-
|
75
|
+
form.should have_selector("select#<%= var_name %>_<%= attribute.name %>", :name => "<%= var_name %>[<%= attribute.name %>]")
|
76
|
+
form.should have_selector("select#<%= var_name %>_<%= attribute.name %>", :name => "<%= var_name %>[<%= attribute.name %>]")
|
77
|
+
form.should have_selector("select#<%= var_name %>_<%= attribute.name %>", :name => "<%= var_name %>[<%= attribute.name %>]")
|
70
78
|
<%- end -%>
|
71
79
|
<%- if [:time, :datetime].include? attribute.type -%>
|
72
|
-
|
73
|
-
|
80
|
+
form.should have_selector("select#<%= var_name %>_<%= attribute.name %>", :name => "<%= var_name %>[<%= attribute.name %>]")
|
81
|
+
form.should have_selector("select#<%= var_name %>_<%= attribute.name %>", :name => "<%= var_name %>[<%= attribute.name %>]")
|
74
82
|
<%- end -%>
|
75
83
|
<% end -%>
|
76
|
-
|
84
|
+
end
|
77
85
|
<% else -%>
|
78
|
-
|
79
|
-
|
86
|
+
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
87
|
+
assert_select "form[action=?][method=?]", <%= t_helper.controller_show_route "@#{var_name}" %>, "post" do
|
80
88
|
<% for attribute in datetime_attributes -%>
|
81
|
-
|
89
|
+
# <%= attribute.name %> values
|
82
90
|
<%- if [:date, :datetime].include? attribute.type -%>
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
91
|
+
assert_select "select#<%= var_name %>_<%= attribute.name %>_1i[name=?]", "<%= var_name %>[<%= attribute.name %>(1i)]" do
|
92
|
+
assert_select "option[selected=selected]", :text => "<%= t_helper.date_select_year_value attribute.default %>", :count => 1
|
93
|
+
end
|
94
|
+
assert_select "select#<%= var_name %>_<%= attribute.name %>_2i[name=?]", "<%= var_name %>[<%= attribute.name %>(2i)]" do
|
95
|
+
assert_select "option[selected=selected][value=?]", "<%= t_helper.date_select_month_value attribute.default %>", :text => "<%= t_helper.date_select_month_text attribute.default %>", :count => 1
|
96
|
+
end
|
97
|
+
assert_select "select#<%= var_name %>_<%= attribute.name %>_3i[name=?]", "<%= var_name %>[<%= attribute.name %>(3i)]" do
|
98
|
+
assert_select "option[selected=selected]", :text => "<%= t_helper.date_select_day_value attribute.default %>", :count => 1
|
99
|
+
end
|
92
100
|
<%- end -%>
|
93
101
|
<%- if [:time, :datetime].include? attribute.type -%>
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
102
|
+
assert_select "select#<%= var_name %>_<%= attribute.name %>_4i[name=?]", "<%= var_name %>[<%= attribute.name %>(4i)]" do
|
103
|
+
assert_select "option[selected=selected]", :text => "<%= t_helper.date_select_hour_value attribute.default %>", :count => 1
|
104
|
+
end
|
105
|
+
assert_select "select#<%= var_name %>_<%= attribute.name %>_5i[name=?]", "<%= var_name %>[<%= attribute.name %>(5i)]" do
|
106
|
+
assert_select "option[selected=selected]", :text => "<%= t_helper.date_select_minute_value attribute.default %>", :count => 1
|
107
|
+
end
|
100
108
|
<%- end -%>
|
101
109
|
<% end -%>
|
102
|
-
|
110
|
+
end
|
103
111
|
<% end -%>
|
104
|
-
|
112
|
+
end
|
105
113
|
|
106
114
|
<% end -%>
|
115
|
+
end
|
107
116
|
end
|
data/lib/generators/authorized_rails_scaffolds/install_templates/templates/spec/index_spec.rb
CHANGED
@@ -17,10 +17,11 @@ output_attributes = t_helper.output_attributes
|
|
17
17
|
|
18
18
|
-%>
|
19
19
|
describe "<%= ns_table_name %>/index" do
|
20
|
+
|
20
21
|
before(:each) do
|
21
|
-
|
22
|
-
@<%= model.underscore %> =
|
23
|
-
|
22
|
+
<%- AuthorizedRailsScaffolds.parent_models.each do |model| -%>
|
23
|
+
@<%= model.underscore %> = FactoryGirl.build_stubbed(:<%= model.underscore %>)
|
24
|
+
<%- end -%>
|
24
25
|
<% [1,2].each_with_index do |id, model_index| -%>
|
25
26
|
@<%= var_name %>_<%= model_index + 1 %> = FactoryGirl.build_stubbed(:<%= var_name %><%= output_attributes.empty? ? ')' : ',' %>
|
26
27
|
<% output_attributes.each_with_index do |attribute, attribute_index| -%>
|
@@ -35,148 +36,153 @@ describe "<%= ns_table_name %>/index" do
|
|
35
36
|
@<%= var_name %>_<%= id %><%= model_index == 1 ? '' : ',' %>
|
36
37
|
<% end -%>
|
37
38
|
])
|
38
|
-
@ability = Object.new
|
39
|
-
@ability.extend(CanCan::Ability)
|
40
|
-
controller.stub(:current_ability) { @ability }
|
41
39
|
end
|
42
40
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
<% else -%>
|
49
|
-
assert_select ".page-header>h1", :text => <%= var_name.humanize.pluralize.dump %>, :count => 1
|
50
|
-
<% end -%>
|
41
|
+
context do # Within default nesting
|
42
|
+
before(:each) do
|
43
|
+
@ability = Object.new
|
44
|
+
@ability.extend(CanCan::Ability)
|
45
|
+
controller.stub(:current_ability) { @ability }
|
51
46
|
end
|
52
|
-
end
|
53
47
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
<% unless webrat? -%>
|
58
|
-
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
59
|
-
<% end -%>
|
60
|
-
<% [1,2].each do |model_index| -%>
|
48
|
+
describe "page header" do
|
49
|
+
it 'includes a h1 title' do
|
50
|
+
render
|
61
51
|
<% if webrat? -%>
|
62
|
-
|
52
|
+
rendered.should have_selector(".page-header>h1", :content => <%= var_name.humanize.pluralize.dump %>, :count => 1)
|
63
53
|
<% else -%>
|
64
|
-
|
65
|
-
<% end -%>
|
54
|
+
assert_select ".page-header>h1", :text => <%= var_name.humanize.pluralize.dump %>, :count => 1
|
66
55
|
<% end -%>
|
56
|
+
end
|
67
57
|
end
|
68
58
|
|
69
|
-
|
70
|
-
|
59
|
+
describe "<%= plural_var_name %> table" do
|
60
|
+
it 'includes a row for each <%= var_name %>' do
|
61
|
+
render
|
71
62
|
<% unless webrat? -%>
|
72
|
-
|
63
|
+
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
73
64
|
<% end -%>
|
74
65
|
<% [1,2].each do |model_index| -%>
|
75
66
|
<% if webrat? -%>
|
76
|
-
|
67
|
+
rendered.should have_selector("table>tbody>tr.<%= var_name %>_#{@<%= var_name %>_<%= model_index %>.id}", :count => 1)
|
77
68
|
<% else -%>
|
78
|
-
|
69
|
+
assert_select "table>tbody>tr.<%= var_name %>_#{@<%= var_name %>_<%= model_index %>.id}", :count => 1
|
79
70
|
<% end -%>
|
80
71
|
<% end -%>
|
81
|
-
|
82
|
-
<% if webrat? -%>
|
83
|
-
rendered.should have_selector("tr>td", :content => <%= factory_attribute_string attribute.type, value_for(attribute) %>.to_s, :count => 2)
|
84
|
-
<% else -%>
|
85
|
-
assert_select "tr>td", :text => <%= t_helper.factory_attribute_string attribute.type, value_for(attribute) %>.to_s, :count => 2
|
86
|
-
<% end -%>
|
87
|
-
<% end -%>
|
88
|
-
end
|
72
|
+
end
|
89
73
|
|
90
|
-
|
91
|
-
it "renders a link to <%= ns_file_name %>_path" do
|
74
|
+
it "contains a list of <%= plural_var_name %>" do
|
92
75
|
render
|
76
|
+
<% unless webrat? -%>
|
77
|
+
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
78
|
+
<% end -%>
|
93
79
|
<% [1,2].each do |model_index| -%>
|
94
|
-
|
95
|
-
rendered.should have_selector("td
|
96
|
-
|
97
|
-
assert_select "td
|
80
|
+
<%- if webrat? -%>
|
81
|
+
rendered.should have_selector("tr>td.id-column", :content => @<%= var_name %>_<%= model_index %>.id.to_s, :count => 1)
|
82
|
+
<%- else -%>
|
83
|
+
assert_select "tr>td.id-column", :text => @<%= var_name %>_<%= model_index %>.id.to_s, :count => 1
|
84
|
+
<%- end -%>
|
98
85
|
<% end -%>
|
86
|
+
<% output_attributes.each_with_index do |attribute, attribute_index| -%>
|
87
|
+
<%- if webrat? -%>
|
88
|
+
rendered.should have_selector("tr>td", :content => <%= factory_attribute_string attribute.type, value_for(attribute) %>.to_s, :count => 2)
|
89
|
+
<%- else -%>
|
90
|
+
assert_select "tr>td", :text => <%= t_helper.factory_attribute_string attribute.type, value_for(attribute) %>.to_s, :count => 2
|
91
|
+
<%- end -%>
|
99
92
|
<% end -%>
|
100
93
|
end
|
101
|
-
end
|
102
94
|
|
103
|
-
|
104
|
-
|
105
|
-
it "renders a disabled link to edit_<%= ns_file_name %>_path" do
|
95
|
+
describe 'show <%= var_name %> link' do
|
96
|
+
it "renders a link to <%= ns_file_name %>_path" do
|
106
97
|
render
|
107
98
|
<% [1,2].each do |model_index| -%>
|
108
|
-
|
109
|
-
rendered.
|
110
|
-
|
111
|
-
assert_select "td>a[href=?][
|
112
|
-
|
99
|
+
<%- if webrat? -%>
|
100
|
+
rendered.should have_selector("td>a[href]:not([data-method])", :href => <%= t_helper.controller_show_route "@#{var_name}_#{model_index}" %>, :count => 1)
|
101
|
+
<%- else -%>
|
102
|
+
assert_select "td>a[href=?]:not([data-method])", <%= t_helper.controller_show_route "@#{var_name}_#{model_index}" %>, :count => 1
|
103
|
+
<%- end -%>
|
113
104
|
<% end -%>
|
114
105
|
end
|
115
106
|
end
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
107
|
+
|
108
|
+
describe 'edit <%= var_name %> link' do
|
109
|
+
context 'without update permissions' do
|
110
|
+
it "renders a disabled link to edit_<%= ns_file_name %>_path" do
|
111
|
+
render
|
120
112
|
<% [1,2].each do |model_index| -%>
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
113
|
+
<%- if webrat? -%>
|
114
|
+
rendered.should_not have_selector("td>a[href][disabled=disabled]", :href => edit_<%= t_helper.controller_show_route "@#{var_name}_#{model_index}" %>, :count => 1)
|
115
|
+
<%- else -%>
|
116
|
+
assert_select "td>a[href=?][disabled=disabled]", edit_<%= t_helper.controller_show_route "@#{var_name}_#{model_index}" %>, :count => 1
|
117
|
+
<%- end -%>
|
125
118
|
<% end -%>
|
119
|
+
end
|
120
|
+
end
|
121
|
+
context 'with update permissions' do
|
122
|
+
it "renders a link to edit_<%= ns_file_name %>_path" do
|
123
|
+
@ability.can :update, <%= local_class_name %>
|
124
|
+
render
|
125
|
+
<% [1,2].each do |model_index| -%>
|
126
|
+
<%- if webrat? -%>
|
127
|
+
rendered.should have_selector("td>a[href]:not([disabled])", :href => edit_<%= t_helper.controller_show_route "@#{var_name}_#{model_index}" %>, :count => 1)
|
128
|
+
<%- else -%>
|
129
|
+
assert_select "td>a[href=?]:not([disabled])", edit_<%= t_helper.controller_show_route "@#{var_name}_#{model_index}" %>, :count => 1
|
130
|
+
<%- end -%>
|
126
131
|
<% end -%>
|
132
|
+
end
|
127
133
|
end
|
128
134
|
end
|
129
|
-
end
|
130
135
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
136
|
+
describe 'destroy <%= var_name %> link' do
|
137
|
+
context 'without destroy permissions' do
|
138
|
+
it "renders a disabled link to <%= ns_file_name %>_path" do
|
139
|
+
render
|
135
140
|
<% [1,2].each do |model_index| -%>
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
+
<%- if webrat? -%>
|
142
|
+
rendered.should_not have_selector("td>a[href][data-method=delete][disabled=disabled]", :href => <%= t_helper.controller_show_route "@#{var_name}_#{model_index}" %>, :count => 1)
|
143
|
+
<%- else -%>
|
144
|
+
assert_select "td>a[href=?][data-method=delete][disabled=disabled]", <%= t_helper.controller_show_route "@#{var_name}_#{model_index}" %>, :count => 1
|
145
|
+
<%- end -%>
|
141
146
|
<% end -%>
|
147
|
+
end
|
142
148
|
end
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
render
|
149
|
+
context 'with destroy permissions' do
|
150
|
+
it "renders a link to <%= ns_file_name %>_path" do
|
151
|
+
@ability.can :destroy, <%= local_class_name %>
|
152
|
+
render
|
148
153
|
<% [1,2].each do |model_index| -%>
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
+
<%- if webrat? -%>
|
155
|
+
rendered.should have_selector("td>a[href][data-method=delete]:not([disabled])", :href => <%= t_helper.controller_show_route "@#{var_name}_#{model_index}" %>, :count => 1)
|
156
|
+
<%- else -%>
|
157
|
+
assert_select "td>a[href=?][data-method=delete]:not([disabled])", <%= t_helper.controller_show_route "@#{var_name}_#{model_index}" %>, :count => 1
|
158
|
+
<%- end -%>
|
154
159
|
<% end -%>
|
160
|
+
end
|
155
161
|
end
|
156
162
|
end
|
157
163
|
end
|
158
|
-
end
|
159
164
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
165
|
+
describe 'new <%= var_name %> link' do
|
166
|
+
context 'without create permissions' do
|
167
|
+
it "does not render a link to new_<%= ns_file_name %>_path" do
|
168
|
+
render
|
164
169
|
<% if webrat? -%>
|
165
|
-
|
170
|
+
rendered.should_not have_selector("a[href=?]", :href => new_<%= t_helper.controller_show_route %>, :count => 1)
|
166
171
|
<% else -%>
|
167
|
-
|
172
|
+
assert_select "a[href=?]", new_<%= t_helper.controller_show_route %>, :count => 0
|
168
173
|
<% end -%>
|
174
|
+
end
|
169
175
|
end
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
render
|
176
|
+
context 'with create permissions' do
|
177
|
+
it "renders a link to new_<%= ns_file_name %>_path" do
|
178
|
+
@ability.can :create, <%= local_class_name %>
|
179
|
+
render
|
175
180
|
<% if webrat? -%>
|
176
|
-
|
181
|
+
rendered.should have_selector("a[href=?]", new_<%= t_helper.controller_show_route %>, :count => 1)
|
177
182
|
<% else -%>
|
178
|
-
|
183
|
+
assert_select "a[href=?]", new_<%= t_helper.controller_show_route %>, :count => 1
|
179
184
|
<% end -%>
|
185
|
+
end
|
180
186
|
end
|
181
187
|
end
|
182
188
|
end
|
@@ -19,87 +19,95 @@ datetime_attributes = t_helper.datetime_attributes
|
|
19
19
|
-%>
|
20
20
|
describe "<%= ns_table_name %>/new" do
|
21
21
|
before(:each) do
|
22
|
-
|
23
|
-
@<%= model.underscore %> =
|
24
|
-
|
22
|
+
<%- AuthorizedRailsScaffolds.parent_models.each do |model| -%>
|
23
|
+
@<%= model.underscore %> = FactoryGirl.build_stubbed(:<%= model.underscore %>)
|
24
|
+
<%- end -%>
|
25
25
|
assign(:<%= var_name %>, FactoryGirl.build(:<%= var_name %><%= output_attributes.empty? ? '))' : ',' %>
|
26
26
|
<% output_attributes.each_with_index do |attribute, attribute_index| -%>
|
27
27
|
:<%= attribute.name %> => <%= t_helper.factory_attribute_value attribute.type, value_for(attribute) %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
|
28
28
|
<% end -%>
|
29
29
|
<%= !output_attributes.empty? ? " ))\n end" : " end" %>
|
30
30
|
|
31
|
-
|
32
|
-
|
31
|
+
context do # Within default nesting
|
32
|
+
before(:each) do
|
33
|
+
<%- AuthorizedRailsScaffolds.parent_models.each do |model| -%>
|
34
|
+
assign(:<%= model.underscore %>, @<%= model.underscore %>)
|
35
|
+
<%- end -%>
|
36
|
+
end
|
37
|
+
|
38
|
+
it "renders new <%= var_name %> form" do
|
39
|
+
render
|
33
40
|
|
34
41
|
<% if webrat? -%>
|
35
|
-
|
42
|
+
rendered.should have_selector("form", :action => <%= t_helper.controller_index_path %>, :method => "post") do |form|
|
36
43
|
<% for attribute in standard_attributes -%>
|
37
44
|
<%- if attribute.type == :references -%>
|
38
|
-
|
45
|
+
form.should have_selector("select#<%= var_name %>_<%= attribute.name %>_id", :name => "<%= var_name %>[<%= attribute.name %>_id]")
|
39
46
|
<%- else -%>
|
40
|
-
|
47
|
+
form.should have_selector("<%= attribute.input_type -%>#<%= var_name %>_<%= attribute.name %>", :name => "<%= var_name %>[<%= attribute.name %>]")
|
41
48
|
<%- end -%>
|
42
49
|
<% end -%>
|
43
|
-
|
50
|
+
end
|
44
51
|
<% else -%>
|
45
|
-
|
46
|
-
|
52
|
+
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
53
|
+
assert_select "form[action=?][method=?]", <%= t_helper.controller_index_path %>, "post" do
|
47
54
|
<% for attribute in standard_attributes -%>
|
48
55
|
<%- if attribute.type == :references -%>
|
49
|
-
|
56
|
+
assert_select "select#<%= var_name %>_<%= attribute.name %>_id[name=?]", "<%= var_name %>[<%= attribute.name %>_id]"
|
50
57
|
<%- else -%>
|
51
|
-
|
58
|
+
assert_select "<%= attribute.input_type -%>#<%= var_name %>_<%= attribute.name %>[name=?]", "<%= var_name %>[<%= attribute.name %>]"
|
52
59
|
<%- end -%>
|
53
60
|
<% end -%>
|
54
|
-
|
61
|
+
end
|
55
62
|
<% end -%>
|
56
|
-
|
63
|
+
end
|
57
64
|
|
58
65
|
<% if datetime_attributes.any? -%>
|
59
|
-
|
60
|
-
|
66
|
+
it "renders all date/time form elements" do
|
67
|
+
render
|
61
68
|
|
62
69
|
<% if webrat? -%>
|
63
|
-
|
70
|
+
rendered.should have_selector("form", :action => <%= t_helper.controller_index_path %>, :method => "post") do |form|
|
64
71
|
<% for attribute in datetime_attributes -%>
|
65
72
|
<%- if [:date, :datetime].include? attribute.type -%>
|
66
|
-
|
67
|
-
|
68
|
-
|
73
|
+
form.should have_selector("select#<%= var_name %>_<%= attribute.name %>", :name => "<%= var_name %>[<%= attribute.name %>]")
|
74
|
+
form.should have_selector("select#<%= var_name %>_<%= attribute.name %>", :name => "<%= var_name %>[<%= attribute.name %>]")
|
75
|
+
form.should have_selector("select#<%= var_name %>_<%= attribute.name %>", :name => "<%= var_name %>[<%= attribute.name %>]")
|
69
76
|
<%- end -%>
|
70
77
|
<%- if [:time, :datetime].include? attribute.type -%>
|
71
|
-
|
72
|
-
|
78
|
+
form.should have_selector("select#<%= var_name %>_<%= attribute.name %>", :name => "<%= var_name %>[<%= attribute.name %>]")
|
79
|
+
form.should have_selector("select#<%= var_name %>_<%= attribute.name %>", :name => "<%= var_name %>[<%= attribute.name %>]")
|
73
80
|
<%- end -%>
|
74
81
|
<% end -%>
|
75
|
-
|
82
|
+
end
|
76
83
|
<% else -%>
|
77
|
-
|
78
|
-
|
84
|
+
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
85
|
+
assert_select "form[action=?][method=?]", <%= t_helper.controller_index_path %>, "post" do
|
79
86
|
<% for attribute in datetime_attributes -%>
|
80
|
-
|
87
|
+
# <%= attribute.name %> values
|
81
88
|
<%- if [:date, :datetime].include? attribute.type -%>
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
89
|
+
assert_select "select#<%= var_name %>_<%= attribute.name %>_1i[name=?]", "<%= var_name %>[<%= attribute.name %>(1i)]" do
|
90
|
+
assert_select "option[selected=selected]", :text => "<%= t_helper.date_select_year_value attribute.default %>", :count => 1
|
91
|
+
end
|
92
|
+
assert_select "select#<%= var_name %>_<%= attribute.name %>_2i[name=?]", "<%= var_name %>[<%= attribute.name %>(2i)]" do
|
93
|
+
assert_select "option[selected=selected][value=?]", "<%= t_helper.date_select_month_value attribute.default %>", :text => "<%= t_helper.date_select_month_text attribute.default %>", :count => 1
|
94
|
+
end
|
95
|
+
assert_select "select#<%= var_name %>_<%= attribute.name %>_3i[name=?]", "<%= var_name %>[<%= attribute.name %>(3i)]" do
|
96
|
+
assert_select "option[selected=selected]", :text => "<%= t_helper.date_select_day_value attribute.default %>", :count => 1
|
97
|
+
end
|
91
98
|
<%- end -%>
|
92
99
|
<%- if [:time, :datetime].include? attribute.type -%>
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
100
|
+
assert_select "select#<%= var_name %>_<%= attribute.name %>_4i[name=?]", "<%= var_name %>[<%= attribute.name %>(4i)]" do
|
101
|
+
assert_select "option[selected=selected]", :text => "<%= t_helper.date_select_hour_value attribute.default %>", :count => 1
|
102
|
+
end
|
103
|
+
assert_select "select#<%= var_name %>_<%= attribute.name %>_5i[name=?]", "<%= var_name %>[<%= attribute.name %>(5i)]" do
|
104
|
+
assert_select "option[selected=selected]", :text => "<%= t_helper.date_select_minute_value attribute.default %>", :count => 1
|
105
|
+
end
|
99
106
|
<%- end -%>
|
100
107
|
<% end -%>
|
101
|
-
|
108
|
+
end
|
102
109
|
<% end -%>
|
110
|
+
end
|
103
111
|
end
|
104
112
|
|
105
113
|
<% end -%>
|