@@ -17,6 +17,9 @@ describe "auth", ->
17
17
@room .robot .brain .userForId " amy" ,
18
18
name : " amy"
19
19
20
+ @room .robot .brain .userForId " jimmy jones" ,
21
+ name : " jimmy jones"
22
+
20
23
afterEach ->
21
24
@room .destroy ()
22
25
@@ -37,6 +40,13 @@ describe "auth", ->
37
40
[" hubot" , " @alice OK, alice has the 'demo' role." ]
38
41
]
39
42
43
+ it " admin user successfully sets role for user with space in name" , ->
44
+ @room .user .say (" alice" , " hubot: jimmy jones has demo role" ).then =>
45
+ expect (@room .messages ).to .eql [
46
+ [" alice" , " hubot: jimmy jones has demo role" ]
47
+ [" hubot" , " @alice OK, jimmy jones has the 'demo' role." ]
48
+ ]
49
+
40
50
41
51
it " fail to add admin role via command" , ->
42
52
@room .user .say (" alice" , " hubot: jimmy has admin role" ).then =>
@@ -70,6 +80,17 @@ describe "auth", ->
70
80
[" hubot" , " @alice Sorry, the 'admin' role can only be removed from the HUBOT_AUTH_ADMIN env variable." ]
71
81
]
72
82
83
+
84
+ it " admin user successfully removes role from user with space" , ->
85
+ @room .user .say (" alice" , " hubot: jimmy jones has demo role" ).then =>
86
+ @room .user .say (" alice" , " hubot: jimmy jones doesn't have demo role" ).then =>
87
+ expect (@room .messages ).to .eql [
88
+ [" alice" , " hubot: jimmy jones has demo role" ]
89
+ [" hubot" , " @alice OK, jimmy jones has the 'demo' role." ]
90
+ [" alice" , " hubot: jimmy jones doesn't have demo role" ]
91
+ [" hubot" , " @alice OK, jimmy jones doesn't have the 'demo' role." ]
92
+ ]
93
+
73
94
context " what roles does <user> have" , ->
74
95
beforeEach ->
75
96
@room .user .say (" alice" , " hubot: alice has demo role" )
@@ -99,20 +120,28 @@ describe "auth", ->
99
120
]
100
121
101
122
context " list assigned roles" , ->
102
- beforeEach ->
103
- @room .user .say (" alice" , " hubot: alice has demo role" ).then =>
104
- @room .user .say (" alice" , " hubot: amy has test role" ).then =>
105
- @room .user .say " alice" , " hubot: alice has test role"
106
-
107
123
it " successfully list assigned roles" , ->
108
- @room .user .say (" alice" , " hubot: list assigned roles" ).then =>
124
+ @room .user .say (" alice" , " hubot: alice has demo role" ).then =>
125
+ @room .user .say (" alice" , " hubot: amy has test role" ).then =>
126
+ @room .user .say (" alice" , " hubot: alice has test role" ).then =>
127
+ @room .user .say (" alice" , " hubot: list assigned roles" ).then =>
128
+ expect (@room .messages ).to .eql [
129
+ [" alice" , " hubot: alice has demo role" ]
130
+ [" hubot" , " @alice OK, alice has the 'demo' role." ]
131
+ [" alice" , " hubot: amy has test role" ]
132
+ [" hubot" , " @alice OK, amy has the 'test' role." ]
133
+ [" alice" , " hubot: alice has test role" ]
134
+ [" hubot" , " @alice OK, alice has the 'test' role." ]
135
+ [" alice" , " hubot: list assigned roles" ]
136
+ [" hubot" , " @alice The following roles are available: demo, test" ]
137
+ ]
138
+
139
+ it " successfully lists roles of user with space in name" , ->
140
+ @room .user .say (" alice" , " hubot: jimmy jones has demo role" ).then =>
141
+ @room .user .say (" amy" , " hubot: what roles does jimmy jones have?" ).then =>
109
142
expect (@room .messages ).to .eql [
110
- [" alice" , " hubot: alice has demo role" ]
111
- [" hubot" , " @alice OK, alice has the 'demo' role." ]
112
- [" alice" , " hubot: amy has test role" ]
113
- [" hubot" , " @alice OK, amy has the 'test' role." ]
114
- [" alice" , " hubot: alice has test role" ]
115
- [" hubot" , " @alice OK, alice has the 'test' role." ]
116
- [" alice" , " hubot: list assigned roles" ]
117
- [" hubot" , " @alice The following roles are available: demo, test" ]
118
- ]
143
+ [" alice" , " hubot: jimmy jones has demo role" ]
144
+ [" hubot" , " @alice OK, jimmy jones has the 'demo' role." ]
145
+ [" amy" , " hubot: what roles does jimmy jones have?" ]
146
+ [" hubot" , " @amy jimmy jones has the following roles: demo." ]
147
+ ]
0 commit comments