mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-05-04 09:54:00 -04:00
Strip spaces from group names upon creation
This commit is contained in:
parent
38b8e9b1b4
commit
b223cdb493
2 changed files with 25 additions and 11 deletions
|
@ -31,7 +31,7 @@ class Admin::GroupsController < Admin::AdminController
|
||||||
|
|
||||||
def create
|
def create
|
||||||
group = Group.new
|
group = Group.new
|
||||||
group.name = params[:group][:name]
|
group.name = params[:group][:name].strip
|
||||||
group.usernames = params[:group][:usernames] if params[:group][:usernames]
|
group.usernames = params[:group][:usernames] if params[:group][:usernames]
|
||||||
group.save!
|
group.save!
|
||||||
render_serialized(group, BasicGroupSerializer)
|
render_serialized(group, BasicGroupSerializer)
|
||||||
|
|
|
@ -48,19 +48,33 @@ describe Admin::GroupsController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is able to create a group" do
|
context '.create' do
|
||||||
xhr :post, :create, group: {
|
let(:usernames) { @admin.username }
|
||||||
usernames: @admin.username,
|
|
||||||
name: "bob"
|
|
||||||
}
|
|
||||||
|
|
||||||
response.status.should == 200
|
it "is able to create a group" do
|
||||||
|
xhr :post, :create, group: {
|
||||||
|
usernames: usernames,
|
||||||
|
name: "bob"
|
||||||
|
}
|
||||||
|
|
||||||
groups = Group.where(name: "bob").to_a
|
response.status.should == 200
|
||||||
|
|
||||||
groups.count.should == 1
|
groups = Group.where(name: "bob").to_a
|
||||||
groups[0].usernames.should == @admin.username
|
|
||||||
groups[0].name.should == "bob"
|
groups.count.should == 1
|
||||||
|
groups[0].usernames.should == usernames
|
||||||
|
groups[0].name.should == "bob"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "strips spaces from group name" do
|
||||||
|
lambda {
|
||||||
|
xhr :post, :create, group: {
|
||||||
|
usernames: usernames,
|
||||||
|
name: " bob "
|
||||||
|
}
|
||||||
|
}.should_not raise_error(ActiveRecord::RecordInvalid)
|
||||||
|
Group.where(name: "bob").count.should == 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is able to update group members" do
|
it "is able to update group members" do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue