diff options
Diffstat (limited to 'spec/models/concerns/project_features_compatibility_spec.rb')
-rw-r--r-- | spec/models/concerns/project_features_compatibility_spec.rb | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/spec/models/concerns/project_features_compatibility_spec.rb b/spec/models/concerns/project_features_compatibility_spec.rb index 1fe176ab5af..8346c4ad4cc 100644 --- a/spec/models/concerns/project_features_compatibility_spec.rb +++ b/spec/models/concerns/project_features_compatibility_spec.rb @@ -4,8 +4,8 @@ require 'spec_helper' describe ProjectFeaturesCompatibility do let(:project) { create(:project) } - let(:features_except_repository) { %w(issues wiki builds merge_requests snippets) } - let(:features) { features_except_repository + ['repository'] } + let(:features_enabled) { %w(issues wiki builds merge_requests snippets) } + let(:features) { features_enabled + %w(repository pages) } # We had issues_enabled, snippets_enabled, builds_enabled, merge_requests_enabled and issues_enabled fields on projects table # All those fields got moved to a new table called project_feature and are now integers instead of booleans @@ -13,37 +13,53 @@ describe ProjectFeaturesCompatibility do # So we can keep it compatible it "converts fields from 'true' to ProjectFeature::ENABLED" do - features_except_repository.each do |feature| + features_enabled.each do |feature| project.update_attribute("#{feature}_enabled".to_sym, "true") expect(project.project_feature.public_send("#{feature}_access_level")).to eq(ProjectFeature::ENABLED) end end it "converts fields from 'false' to ProjectFeature::DISABLED" do - features_except_repository.each do |feature| + features_enabled.each do |feature| project.update_attribute("#{feature}_enabled".to_sym, "false") expect(project.project_feature.public_send("#{feature}_access_level")).to eq(ProjectFeature::DISABLED) end end it "converts fields from true to ProjectFeature::ENABLED" do - features_except_repository.each do |feature| + features_enabled.each do |feature| project.update_attribute("#{feature}_enabled".to_sym, true) expect(project.project_feature.public_send("#{feature}_access_level")).to eq(ProjectFeature::ENABLED) end end it "converts fields from false to ProjectFeature::DISABLED" do - features_except_repository.each do |feature| + features_enabled.each do |feature| project.update_attribute("#{feature}_enabled".to_sym, false) expect(project.project_feature.public_send("#{feature}_access_level")).to eq(ProjectFeature::DISABLED) end end - it "accepts private as ProjectFeature::PRIVATE" do - features.each do |feature| - project.update!("#{feature}_access_level".to_sym => 'private') - expect(project.project_feature.public_send("#{feature}_access_level")).to eq(ProjectFeature::PRIVATE) + describe "access levels" do + using RSpec::Parameterized::TableSyntax + + where(:access_level, :expected_result) do + 'disabled' | ProjectFeature::DISABLED + 'private' | ProjectFeature::PRIVATE + 'enabled' | ProjectFeature::ENABLED + 'public' | ProjectFeature::PUBLIC + end + + with_them do + it "accepts access level" do + features.each do |feature| + # Only pages as public access level + next if feature != 'pages' && access_level == 'public' + + project.update!("#{feature}_access_level".to_sym => access_level) + expect(project.project_feature.public_send("#{feature}_access_level")).to eq(expected_result) + end + end end end end |