Allow badges to be marked as "titleable".

This commit is contained in:
Vikhyat Korrapati
2014-04-28 10:30:38 +05:30
parent 535965263a
commit b4e037dfb2
15 changed files with 51 additions and 26 deletions
@@ -35,12 +35,12 @@ describe Admin::BadgesController do
context '.update' do
it 'returns success' do
xhr :put, :update, id: badge.id, name: "123456", badge_type_id: badge.badge_type_id
xhr :put, :update, id: badge.id, name: "123456", badge_type_id: badge.badge_type_id, allow_title: false
response.should be_success
end
it 'updates the badge' do
xhr :put, :update, id: badge.id, name: "123456", badge_type_id: badge.badge_type_id
xhr :put, :update, id: badge.id, name: "123456", badge_type_id: badge.badge_type_id, allow_title: false
badge.reload.name.should eq('123456')
end
end
+2 -2
View File
@@ -5,7 +5,7 @@ describe BadgesController do
context 'index' do
it 'should return a list of all badges' do
xhr :get, :index
get :index, format: :json
response.status.should == 200
parsed = JSON.parse(response.body)
@@ -15,7 +15,7 @@ describe BadgesController do
context 'show' do
it "should return a badge" do
xhr :get, :show, id: badge.id
get :show, id: badge.id, format: :json
response.status.should == 200
parsed = JSON.parse(response.body)
parsed["badge"].should be_present
+15
View File
@@ -996,6 +996,21 @@ describe UsersController do
end
end
describe "badge_title" do
let(:user) { Fabricate(:user) }
let(:badge) { Fabricate(:badge) }
let(:user_badge) { BadgeGranter.grant(badge, user) }
it "sets the user's title to the badge name if it is titleable" do
log_in_user user
xhr :put, :badge_title, user_badge_id: user_badge.id, username: user.username
user.reload.title.should_not == badge.name
badge.update_attributes allow_title: true
xhr :put, :badge_title, user_badge_id: user_badge.id, username: user.username
user.reload.title.should == badge.name
end
end
describe "search_users" do
let(:topic) { Fabricate :topic }