|
255 | 255 | before do
|
256 | 256 | RailsAdmin.config.included_models = [ManagingUser, ManagedTeam]
|
257 | 257 | RailsAdmin.config ManagingUser do
|
258 |
| - field(:teams) { associated_collection_cache_all false } |
| 258 | + field :teams |
259 | 259 | end
|
260 | 260 | end
|
261 | 261 |
|
262 |
| - it "picks up associated model's primary key correctly" do |
| 262 | + it "allows update" do |
263 | 263 | visit edit_path(model_name: 'managing_user', id: user.id)
|
264 | 264 | expect(find("select#managing_user_team_ids option[value=\"#{teams[0].id}\"]")).to have_content teams[0].name
|
265 |
| - end |
266 |
| - |
267 |
| - it "allows update with fetching associated objects via xhr", js: true do |
268 |
| - visit edit_path(model_name: 'managing_user', id: user.id) |
269 |
| - find('input.ra-multiselect-search').set('T') |
270 |
| - page.execute_script("$('input.ra-multiselect-search').trigger('focus')") |
271 |
| - page.execute_script("$('input.ra-multiselect-search').trigger('keydown')") |
272 |
| - find('.ra-multiselect-collection option', text: teams[1].name).select_option |
273 |
| - find('.ra-multiselect-item-add').click |
| 265 | + select(teams[1].name, from: 'Teams') |
274 | 266 | click_button 'Save'
|
275 | 267 | expect(ManagingUser.first.teams).to match_array teams
|
276 | 268 | end
|
| 269 | + |
| 270 | + context 'when fetching associated objects via xhr' do |
| 271 | + before do |
| 272 | + RailsAdmin.config ManagingUser do |
| 273 | + field(:teams) { associated_collection_cache_all false } |
| 274 | + end |
| 275 | + end |
| 276 | + |
| 277 | + it "allows update", js: true do |
| 278 | + visit edit_path(model_name: 'managing_user', id: user.id) |
| 279 | + find('input.ra-multiselect-search').set('T') |
| 280 | + page.execute_script("$('input.ra-multiselect-search').trigger('focus')") |
| 281 | + page.execute_script("$('input.ra-multiselect-search').trigger('keydown')") |
| 282 | + find('.ra-multiselect-collection option', text: teams[1].name).select_option |
| 283 | + find('.ra-multiselect-item-add').click |
| 284 | + click_button 'Save' |
| 285 | + expect(ManagingUser.first.teams).to match_array teams |
| 286 | + end |
| 287 | + end |
277 | 288 | end
|
278 | 289 | end
|
0 commit comments