Hexadecimal color changed to capital letters

The default colors in event_types and difficulty levels are in capital letters and the ones that comes from the color picker were not. Now colors are capitalized before saving the track, level or type. A rake task has also been created to capitalize color from old tracks, levels or types.
This commit is contained in:
Ana 2016-07-04 17:53:21 +02:00
parent 0deaf1abc7
commit 8d9bb56f06
11 changed files with 72 additions and 15 deletions

View file

@ -426,7 +426,7 @@ describe Conference do
result = {}
result['Hard'] = {
'value' => 1,
'color' => '#ffffff',
'color' => '#FFFFFF',
}
result['Easy'] = {
'value' => 2,
@ -476,7 +476,7 @@ describe Conference do
result = {}
result['Hard'] = {
'value' => 1,
'color' => '#ffffff'
'color' => '#FFFFFF'
}
result['Easy'] = {
'value' => 1,
@ -526,7 +526,7 @@ describe Conference do
}
result['Lecture'] = {
'value' => 1,
'color' => '#ffffff',
'color' => '#FFFFFF',
}
expect(subject.event_type_distribution).to eq(result)
end
@ -572,7 +572,7 @@ describe Conference do
result = {}
result['Lecture'] = {
'value' => 1,
'color' => '#ffffff'
'color' => '#FFFFFF'
}
result['Workshop'] = {
'value' => 1,
@ -622,7 +622,7 @@ describe Conference do
}
result['Track Two'] = {
'value' => 1,
'color' => '#ffffff',
'color' => '#FFFFFF',
}
expect(subject.tracks_distribution).to eq(result)
end
@ -672,7 +672,7 @@ describe Conference do
}
result['Track Two'] = {
'value' => 1,
'color' => '#ffffff'
'color' => '#FFFFFF'
}
expect(subject.tracks_distribution(:confirmed)).to eq(result)
end

View file

@ -236,7 +236,7 @@ describe Event do
json_hash = event.as_json(nil)
expect(json_hash[:room_guid]).to eq(event.room.guid)
expect(json_hash[:track_color]).to eq('#efefef')
expect(json_hash[:track_color]).to eq('#EFEFEF')
expect(json_hash[:length]).to eq(30)
end
@ -245,7 +245,7 @@ describe Event do
json_hash = event.as_json(nil)
expect(json_hash[:room_guid]).to be_nil
expect(json_hash[:track_color]).to eq('#ffffff')
expect(json_hash[:track_color]).to eq('#FFFFFF')
expect(json_hash[:length]).to eq(25)
end
end

View file

@ -18,6 +18,22 @@ describe EventType do
it { is_expected.to validate_presence_of(:minimum_abstract_length) }
it { is_expected.to validate_presence_of(:maximum_abstract_length) }
it 'is valid if its color is a correct hexadecimal color with 7 characters' do
should allow_value('#FF0000').for(:color)
end
it 'is not valid if its color is not a correct hexadecimal color' do
should_not allow_value('#AB1H7G').for(:color)
end
it 'is not valid if its color has less than 7 characters' do
should_not allow_value('#fff').for(:color)
end
it 'is not valid if its color has more than 7 characters' do
should_not allow_value('#123A4567').for(:color)
end
describe 'length' do
it 'validates numericality and greater than 0' do
is_expected.to validate_numericality_of(:length).is_greater_than(0)