mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Admin can list enterprise relationships
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
Admin.controller "AdminEnterpriseRelationshipsCtrl", ($scope) ->
|
||||
$scope.hello = "Hello, angular."
|
||||
Admin.controller "AdminEnterpriseRelationshipsCtrl", ($scope, EnterpriseRelationships) ->
|
||||
$scope.EnterpriseRelationships = EnterpriseRelationships
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
Admin.factory 'EnterpriseRelationships', (enterprise_relationships) ->
|
||||
new class EnterpriseRelationships
|
||||
constructor: ->
|
||||
@enterprise_relationships = enterprise_relationships
|
||||
@@ -1,7 +1,7 @@
|
||||
module Admin
|
||||
class EnterpriseRelationshipsController < ResourceController
|
||||
def index
|
||||
|
||||
@enterprise_relationships = EnterpriseRelationship.by_name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,12 +4,16 @@
|
||||
= render 'admin/shared/enterprises_sub_menu'
|
||||
|
||||
%div{"ng-app" => "ofn.admin", "ng-controller" => "AdminEnterpriseRelationshipsCtrl"}
|
||||
:javascript
|
||||
angular.module('ofn.admin').value('enterprise_relationships', #{render partial: "admin/json/enterprise_relationships", object: @enterprise_relationships})
|
||||
-#%pre {{ EnterpriseRelationships.enterprise_relationships | json }}
|
||||
|
||||
%table#enterprise-relationships
|
||||
%thead
|
||||
%tr
|
||||
%th Parent
|
||||
%th Child
|
||||
%tbody
|
||||
%tr
|
||||
%td {{ hello }}
|
||||
%td {{ hello }}
|
||||
%tr{"ng-repeat" => "enterprise_relationship in EnterpriseRelationships.enterprise_relationships"}
|
||||
%td {{ enterprise_relationship.parent_name }}
|
||||
%td {{ enterprise_relationship.child_name }}
|
||||
|
||||
32
spec/features/admin/enterprise_relationships_spec.rb
Normal file
32
spec/features/admin/enterprise_relationships_spec.rb
Normal file
@@ -0,0 +1,32 @@
|
||||
require 'spec_helper'
|
||||
|
||||
feature %q{
|
||||
As an Administrator
|
||||
I want to manage relationships between enterprises
|
||||
}, js: true do
|
||||
include AuthenticationWorkflow
|
||||
include WebHelper
|
||||
|
||||
before { login_to_admin_section }
|
||||
|
||||
scenario "listing relationships" do
|
||||
# Given some enterprises with relationships
|
||||
e1, e2, e3, e4 = create(:enterprise), create(:enterprise), create(:enterprise), create(:enterprise)
|
||||
create(:enterprise_relationship, parent: e1, child: e2)
|
||||
create(:enterprise_relationship, parent: e3, child: e4)
|
||||
|
||||
# When I go to the relationships page
|
||||
click_link 'Enterprises'
|
||||
click_link 'Relationships'
|
||||
|
||||
# Then I should see the relationships
|
||||
within('table#enterprise-relationships') do
|
||||
page.should have_table_row [e1.name, e2.name]
|
||||
page.should have_table_row [e3.name, e4.name]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
scenario "creating a relationship"
|
||||
scenario "deleting a relationship"
|
||||
end
|
||||
Reference in New Issue
Block a user