Commit 0b559cdece743269a7087c8206ab2cc587ec15f2
1 parent
26803717
Exists in
master
and in
4 other branches
add validations for boolean attributes
Showing
5 changed files
with
11 additions
and
3 deletions
Show diff stats
app/models/project.rb
| ... | ... | @@ -104,6 +104,8 @@ class Project < ActiveRecord::Base |
| 104 | 104 | length: { within: 1..255 } |
| 105 | 105 | |
| 106 | 106 | validates :owner, presence: true |
| 107 | + validates :issues_enabled, :wall_enabled, :merge_requests_enabled, | |
| 108 | + :wiki_enabled, inclusion: { in: [true, false] } | |
| 107 | 109 | validate :check_limit |
| 108 | 110 | validate :repo_name |
| 109 | 111 | ... | ... |
app/roles/issue_commonality.rb
spec/models/issue_spec.rb
spec/models/milestone_spec.rb
| ... | ... | @@ -9,6 +9,7 @@ describe Milestone do |
| 9 | 9 | describe "Validation" do |
| 10 | 10 | it { should validate_presence_of(:title) } |
| 11 | 11 | it { should validate_presence_of(:project_id) } |
| 12 | + it { should ensure_inclusion_of(:closed).in_array([true, false]) } | |
| 12 | 13 | end |
| 13 | 14 | |
| 14 | 15 | let(:milestone) { Factory :milestone } | ... | ... |
spec/models/project_spec.rb
| ... | ... | @@ -37,6 +37,10 @@ describe Project do |
| 37 | 37 | # TODO: Formats |
| 38 | 38 | |
| 39 | 39 | it { should validate_presence_of(:owner) } |
| 40 | + it { should ensure_inclusion_of(:issues_enabled).in_array([true, false]) } | |
| 41 | + it { should ensure_inclusion_of(:wall_enabled).in_array([true, false]) } | |
| 42 | + it { should ensure_inclusion_of(:merge_requests_enabled).in_array([true, false]) } | |
| 43 | + it { should ensure_inclusion_of(:wiki_enabled).in_array([true, false]) } | |
| 40 | 44 | |
| 41 | 45 | it "should not allow new projects beyond user limits" do |
| 42 | 46 | project.stub(:owner).and_return(double(can_create_project?: false, projects_limit: 1)) |
| ... | ... | @@ -239,7 +243,7 @@ describe Project do |
| 239 | 243 | end |
| 240 | 244 | end |
| 241 | 245 | |
| 242 | - describe :update_merge_requests do | |
| 246 | + describe :update_merge_requests do | |
| 243 | 247 | let(:project) { Factory :project } |
| 244 | 248 | |
| 245 | 249 | before do |
| ... | ... | @@ -259,7 +263,7 @@ describe Project do |
| 259 | 263 | @merge_request.closed.should be_true |
| 260 | 264 | end |
| 261 | 265 | |
| 262 | - it "should update merge request commits with new one if pushed to source branch" do | |
| 266 | + it "should update merge request commits with new one if pushed to source branch" do | |
| 263 | 267 | @merge_request.last_commit.should == nil |
| 264 | 268 | project.update_merge_requests("8716fc78f3c65bbf7bcf7b574febd583bc5d2812", "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a", "refs/heads/master", @key.user) |
| 265 | 269 | @merge_request.reload | ... | ... |