       it 'handles a subgroup with subdomain on loom.io', ->
         @group.updateFromJSON subdomain: 'subdomain'
         subgroup = @factory.create 'groups', parent_id: @group.id, key: 'subkey', name: 'subname'
-        expect(@subject.group(subgroup)).toBe 'https://subdomain.loom.io/g/subkey/name-subname'
+        expect(@subject.group(subgroup)).toBe "https://subdomain.loom.io/g/#{subgroup.key}/name-subname"
 
     describe 'on loomio.org', ->
       beforeEach ->

          default_subdomain: 'www'

      it 'handles a group without subdomain on loomio.org', ->
        expect(@subject.group(@group)).toBe 'http://www.loomio.org/g/key/name'

      it 'handles a group with subdomain on loomio.org', ->
        @group.updateFromJSON subdomain: 'subdomain'
        expect(@subject.group(@group)).toBe 'http://subdomain.loomio.org/'

      it 'handles a subgroup with subdomain on loomio.org', ->
        @group.updateFromJSON subdomain: 'subdomain'
        subgroup = @factory.create 'groups', parent_id: @group.id, key: 'subkey', name: 'subname'
        expect(@subject.group(subgroup)).toBe 'http://subdomain.loomio.org/g/subkey/name-subname'

    describe 'on loomio.anotherdomain.com', ->
      beforeEach ->

          ssl: true

      it 'handles a group without subdomain on loom.io', ->
        expect(@subject.group(@group)).toBe "https://loom.io/g/#{@group.key}/name"

      it 'handles a group with subdomain on loom.io', ->
        @group.updateFromJSON subdomain: 'subdomain'
