extracted boolean validation logic into stand-alone validator

This commit is contained in:
Hauke Klement
2015-03-18 09:10:58 +01:00
parent 9be0e12990
commit d109663cb9
9 changed files with 40 additions and 7 deletions

View File

@ -9,6 +9,8 @@ describe CodeOcean::File do
it 'validates the presence of the hidden flag' do
expect(file.errors[:hidden]).to be_present
file.update(hidden: false)
expect(file.errors[:hidden]).to be_blank
end
it 'validates the presence of a name' do
@ -17,6 +19,8 @@ describe CodeOcean::File do
it 'validates the presence of the read-only flag' do
expect(file.errors[:read_only]).to be_present
file.update(read_only: false)
expect(file.errors[:read_only]).to be_blank
end
context 'as a teacher-defined test' do

View File

@ -34,6 +34,8 @@ describe ExecutionEnvironment do
it 'validates the presence of the network enabled flag' do
expect(execution_environment.errors[:network_enabled]).to be_present
execution_environment.update(network_enabled: false)
expect(execution_environment.errors[:network_enabled]).to be_blank
end
it 'validates the numericality of the permitted run time' do

View File

@ -28,6 +28,8 @@ describe Exercise do
it 'validates the presence of the public flag' do
expect(exercise.errors[:public]).to be_present
exercise.update(public: false)
expect(exercise.errors[:public]).to be_blank
end
it 'validates the presence of a title' do

View File

@ -5,6 +5,8 @@ describe FileType do
it 'validates the presence of the binary flag' do
expect(file_type.errors[:binary]).to be_present
file_type.update(binary: false)
expect(file_type.errors[:binary]).to be_blank
end
context 'when binary' do
@ -33,6 +35,8 @@ describe FileType do
it 'validates the presence of the executable flag' do
expect(file_type.errors[:executable]).to be_present
file_type.update(executable: false)
expect(file_type.errors[:executable]).to be_blank
end
it 'validates the presence of a name' do
@ -41,6 +45,8 @@ describe FileType do
it 'validates the presence of the renderable flag' do
expect(file_type.errors[:renderable]).to be_present
file_type.update(renderable: false)
expect(file_type.errors[:renderable]).to be_blank
end
it 'validates the presence of a user' do