diff --git a/app/views/admin/order_cycles/_exchange_form.html.haml b/app/views/admin/order_cycles/_exchange_form.html.haml index 967617eff9..4ed780eb07 100644 --- a/app/views/admin/order_cycles/_exchange_form.html.haml +++ b/app/views/admin/order_cycles/_exchange_form.html.haml @@ -1,5 +1,5 @@ %td.active= check_box_tag 'order_cycle_exchange_{{ $index }}_active', 1, 1, 'ng-model' => 'exchange.active', 'id' => 'order_cycle_exchange_{{ $index }}_active' -%td.supplier_name {{ enterprises[exchange.enterprise_id].name }} +%td{:class => "#{type}_name"} {{ enterprises[exchange.enterprise_id].name }} %td.products = f.submit 'Products', 'ng-click' => 'toggleProducts($event, exchange)' {{ exchangeSelectedVariants(exchange) }} / {{ enterpriseTotalVariants(enterprises[exchange.enterprise_id]) }} selected diff --git a/app/views/admin/order_cycles/_form.html.haml b/app/views/admin/order_cycles/_form.html.haml index bf4b8fe5bc..b08fca0d7e 100644 --- a/app/views/admin/order_cycles/_form.html.haml +++ b/app/views/admin/order_cycles/_form.html.haml @@ -20,7 +20,7 @@ %th Products %tbody{'ng-repeat' => 'exchange in order_cycle.incoming_exchanges'} %tr.supplier - = render 'exchange_form', :f => f + = render 'exchange_form', :f => f, :type => 'supplier' %tr.products{'ng-show' => 'exchange.showProducts'} = render 'exchange_supplied_products_form' @@ -41,7 +41,7 @@ %th Products %tbody{'ng-repeat' => 'exchange in order_cycle.outgoing_exchanges'} %tr.distributor - = render 'exchange_form', :f => f + = render 'exchange_form', :f => f, :type => 'distributor' %tr.products{'ng-show' => 'exchange.showProducts'} = render 'exchange_distributed_products_form' diff --git a/spec/features/admin/order_cycles_spec.rb b/spec/features/admin/order_cycles_spec.rb index 7e3df1713d..8d38278979 100644 --- a/spec/features/admin/order_cycles_spec.rb +++ b/spec/features/admin/order_cycles_spec.rb @@ -108,7 +108,20 @@ feature %q{ page.all('table.exchanges tbody tr.supplier').each do |row| row.find('td.products input').click - products_row = page.find('table.exchanges tr.products') + products_row = page.all('table.exchanges tr.products').select { |r| r.visible? }.first + products_row.should have_selector "input[type='checkbox'][checked='checked']" + + row.find('td.products input').click + end + + # And I should see the distributors with products + page.should have_selector 'td.distributor_name', :text => oc.distributors.first.name + page.should have_selector 'td.distributor_name', :text => oc.distributors.last.name + + page.all('table.exchanges tbody tr.distributor').each do |row| + row.find('td.products input').click + + products_row = page.all('table.exchanges tr.products').select { |r| r.visible? }.first products_row.should have_selector "input[type='checkbox'][checked='checked']" row.find('td.products input').click