Skip to content

Commit

Permalink
Merge pull request loomio#1212 from loomio/rename-secret-to-hidden
Browse files Browse the repository at this point in the history
rename secret to hidden
  • Loading branch information
robguthrie committed Dec 10, 2013
2 parents 1ef566a + 8208adf commit cba33fe
Show file tree
Hide file tree
Showing 25 changed files with 143 additions and 134 deletions.
File renamed without changes
4 changes: 2 additions & 2 deletions app/helpers/groups_helper.rb
Expand Up @@ -87,7 +87,7 @@ def group_privacy_options(group)
header = t "simple_form.labels.group.privacy_#{privacy_setting}_header"
description = t "simple_form.labels.group.privacy_#{privacy_setting}_description"

if privacy_setting != 'secret' && group.is_a_subgroup? && group.parent.privacy == 'secret'
if privacy_setting != 'hidden' && group.is_a_subgroup? && group.parent.privacy == 'hidden'
disabled_class = 'disabled'
text_color = '#CCCCCC'
else
Expand All @@ -101,7 +101,7 @@ def group_privacy_options(group)
end

def group_privacy_options_disabled(group)
if group.is_a_subgroup? && group.parent.privacy == 'secret'
if group.is_a_subgroup? && group.parent.privacy == 'hidden'
['public', 'private']
else
[]
Expand Down
2 changes: 1 addition & 1 deletion app/models/ability.rb
Expand Up @@ -18,7 +18,7 @@ def initialize(user)
true
when 'private'
true
when 'secret'
when 'hidden'
if group.viewable_by_parent_members?
@member_group_ids.include?(group.id) or @member_group_ids.include?(group.parent_id)
else
Expand Down
20 changes: 10 additions & 10 deletions app/models/group.rb
Expand Up @@ -3,7 +3,7 @@ class Group < ActiveRecord::Base
class MaximumMembershipsExceeded < Exception
end

PRIVACY_CATEGORIES = ['public', 'private', 'secret']
PRIVACY_CATEGORIES = ['public', 'private', 'hidden']
INVITER_CATEGORIES = ['members', 'admins']
PAYMENT_PLANS = ['pwyc', 'subscription', 'manual_subscription', 'undetermined']

Expand All @@ -16,7 +16,7 @@ class MaximumMembershipsExceeded < Exception

validate :limit_inheritance
validate :privacy_allowed_by_parent, if: :is_a_subgroup?
validate :subgroups_are_secret, if: :is_secret?
validate :subgroups_are_hidden, if: :is_hidden?

after_initialize :set_defaults
before_save :update_full_name_if_name_changed
Expand Down Expand Up @@ -159,8 +159,8 @@ def privacy_public?
(privacy == 'public') and !archived?
end

def is_secret?
self.privacy == 'secret'
def is_hidden?
self.privacy == 'hidden'
end

def members_can_invite_members?
Expand Down Expand Up @@ -306,7 +306,7 @@ def calculate_full_name
end

def set_defaults
self.privacy ||= 'secret'
self.privacy ||= 'hidden'
self.members_invitable_by ||= 'members'
end

Expand All @@ -317,14 +317,14 @@ def limit_inheritance
end

def privacy_allowed_by_parent
if parent.privacy == 'secret' && self.privacy != 'secret'
errors[:privacy] << "Parent group is secret, subgroups must also be secret"
if parent.privacy == 'hidden' && self.privacy != 'hidden'
errors[:privacy] << "Parent group is hidden, subgroups must also be hidden"
end
end

def subgroups_are_secret
unless subgroups.all?{|g| g.is_secret?}
errors[:privacy] << "There are non secret subgroups, so this group cannot be secret"
def subgroups_are_hidden
unless subgroups.all?{|g| g.is_hidden?}
errors[:privacy] << "There are non hidden subgroups, so this group cannot be hidden"
end
end
end
10 changes: 5 additions & 5 deletions config/locales/en.yml
Expand Up @@ -284,7 +284,7 @@ en:
create_subgroup: "Create sub-group"
creating_subgroup: "Creating sub-group"

secret: "Secret"
hidden: "Hidden"
public: "Public"

new_group: "New group"
Expand Down Expand Up @@ -735,11 +735,11 @@ en:
privacy_private_header: Private
privacy_private_description: Anyone can see the group and who's in it. Discussions are only visible to members by default.
privacy_private_description_short: Anyone can see this group. Only members can see discussions.
privacy_secret_header: Secret
privacy_secret_description: Only members can see the group and its discussions. You cannot have public discussions in a secret group.
privacy_secret_description_short: Only members can see this group and its discussions.
privacy_hidden_header: Hidden
privacy_hidden_description: Only members can see the group and its discussions. You cannot have public discussions in a hidden group.
privacy_hidden_description_short: Only members can see this group and its discussions.
privacy_parent_group_members_header: Viewable by parent group members
privacy_parent_group_members_description: Same as secret, only the group and its discussions can be seen by parent group members.
privacy_parent_group_members_description: Same as hidden, only the group and its discussions can be seen by parent group members.
privacy_parent_group_members_description_short: Only members and parent group members can see this group and its discussions.
group_members_invitable_by:
"Only coordinators"
Expand Down
9 changes: 9 additions & 0 deletions db/migrate/20131209035746_rename_secret_to_hidden.rb
@@ -0,0 +1,9 @@
class RenameSecretToHidden < ActiveRecord::Migration
def up
Group.where(privacy: 'secret').update_all("privacy = 'hidden'")
end

def down
Group.where(privacy: 'hidden').update_all("privacy = 'secret'")
end
end
8 changes: 4 additions & 4 deletions features/groups/membership_request.feature
Expand Up @@ -19,9 +19,9 @@ Feature: Individual requests group membership
And I fill in and submit the Request membership form using email of existing member
Then I should see a field error telling me I am already a member of the group

Scenario: Vistor cannot request membership to secret group
Scenario: Vistor cannot request membership to hidden group
Given I am a visitor
And a secret group exists
And a hidden group exists
When I visit the request membership page for the group
Then I should be asked to log in

Expand Down Expand Up @@ -54,9 +54,9 @@ Feature: Individual requests group membership
And I fill in and submit the Request membership form (introduction only)
Then I should see a flash message confirming my membership request

Scenario: User cannot request membership to secret group
Scenario: User cannot request membership to hidden group
Given I am logged in
And a secret group exists
And a hidden group exists
When I visit the request membership page for the group
Then I should be redirected to the dashboard

Expand Down
2 changes: 1 addition & 1 deletion features/groups/privacy/parent_viewable_group.feature
Expand Up @@ -7,7 +7,7 @@ Feature: User views group
Given I am logged in

Scenario: Coordinator makes subgroup viewable to parent members
Given I am a coordinator of a secret subgroup
Given I am a coordinator of a hidden subgroup
When I visit the edit subgroup page
And I set the subgroup to be viewable by parent members
Then the subgroup should be viewable by parent members
Expand Down
2 changes: 1 addition & 1 deletion features/groups/privacy/private_group.feature
Expand Up @@ -7,7 +7,7 @@ Feature: Coordinator sets group privacy to private
Given I am logged in

Scenario: Coordinator sets group privacy to private
Given I am a coordinator of a secret group
Given I am a coordinator of a hidden group
When I visit the group settings page
And I set the group to private
Then the group should be set to private
Expand Down
2 changes: 1 addition & 1 deletion features/groups/privacy/public_group.feature
Expand Up @@ -7,7 +7,7 @@ Feature: Coordinator sets group privacy to public
Given I am logged in

Scenario: Coordinator sets group privacy to public
Given I am a coordinator of a secret group
Given I am a coordinator of a hidden group
When I visit the group settings page
And I set the group to public
Then the group should be set to public
Expand Down
26 changes: 13 additions & 13 deletions features/groups/privacy/secret_group.feature
@@ -1,37 +1,37 @@
Feature: Coordinator sets group privacy to secret
Feature: Coordinator sets group privacy to hidden
As a group coordinator
I want to make the group secret
I want to make the group hidden
So only members know it exists

Background:
Given I am logged in

Scenario: Coordinator sets group privacy to secret
Scenario: Coordinator sets group privacy to hidden
Given I am a coordinator of a public group
When I visit the group settings page
And I set the group to secret
Then the group should be set to secret
And I set the group to hidden
Then the group should be set to hidden

Scenario: Non-member tries to view secret group
Given a secret group exists
Scenario: Non-member tries to view hidden group
Given a hidden group exists
And the group has discussions
When I visit the group page
Then I should not see the group's discussions

Scenario: Member views secret group
Given I am a member of a secret group
Scenario: Member views hidden group
Given I am a member of a hidden group
And the group has discussions
When I visit the group page
Then I should see the group's discussions

Scenario: Non-member tries to view secret sub-group
Given a secret sub-group exists
Scenario: Non-member tries to view hidden sub-group
Given a hidden sub-group exists
And the sub-group has discussions
When I visit the sub-group page
Then I should not see the sub-group's discussions

Scenario: Member views secret sub-group
Given I am a member of a secret sub-group
Scenario: Member views hidden sub-group
Given I am a member of a hidden sub-group
And the sub-group has discussions
When I visit the sub-group page
Then I should see the sub-group's discussions
4 changes: 2 additions & 2 deletions features/step_definitions/edit_group_settings_steps.rb
Expand Up @@ -7,7 +7,7 @@
end

When /^I update the settings to members only$/ do
choose 'group_privacy_secret'
choose 'group_privacy_hidden'
end

When /^I update the group name$/ do
Expand All @@ -23,7 +23,7 @@
end

Then /^the group should be private$/ do
Group.where(:name=>"New Test Group", :privacy=>"secret").size > 0
Group.where(:name=>"New Test Group", :privacy=>"hidden").size > 0
end

Then /^I should not have access to group settings of "(.*?)"$/ do |group|
Expand Down
46 changes: 23 additions & 23 deletions features/step_definitions/group_privacy_steps.rb
Expand Up @@ -14,10 +14,10 @@
@group.save!
end

Given /^a secret group exists$/ do
Given /^a hidden group exists$/ do
@group = FactoryGirl.create :group
@group.privacy = 'secret'
@group.description = "this group is secret"
@group.privacy = 'hidden'
@group.description = "this group is hidden"
@group.save
end

Expand All @@ -37,16 +37,16 @@
:privacy => 'public'
end

Given /^a secret sub\-group exists$/ do
Given /^a hidden sub\-group exists$/ do
@parent_group = FactoryGirl.create :group
@sub_group = FactoryGirl.create :group, :parent => @parent_group
@sub_group.privacy = 'secret'
@sub_group.privacy = 'hidden'
@sub_group.save
end

Given /^a sub\-group viewable by parent\-group members exists$/ do
@parent_group = FactoryGirl.create :group
@sub_group = FactoryGirl.create :group, :parent => @parent_group, privacy: 'secret', viewable_by_parent_members: true
@sub_group = FactoryGirl.create :group, :parent => @parent_group, privacy: 'hidden', viewable_by_parent_members: true
@sub_group.save
end

Expand All @@ -73,21 +73,21 @@
step "a public group exists"
end

Given /^I am a member of a secret group$/ do
step "a secret group exists"
Given /^I am a member of a hidden group$/ do
step "a hidden group exists"
@group.add_member! @user
end

Given /^a secret group exists that I am not a member of$/ do
step "a secret group exists"
Given /^a hidden group exists that I am not a member of$/ do
step "a hidden group exists"
end

Given /^a public sub\-group exists that I am not a member of$/ do
step "a public sub-group exists"
end

Given /^a secret sub\-group exists that I am not a member of$/ do
step "a secret sub-group exists"
Given /^a hidden sub\-group exists that I am not a member of$/ do
step "a hidden sub-group exists"
end

Given /^I am a member of a public sub\-group$/ do
Expand All @@ -96,8 +96,8 @@
@sub_group.add_member! @user
end

Given /^I am a member of a secret sub\-group$/ do
step "a secret sub-group exists"
Given /^I am a member of a hidden sub\-group$/ do
step "a hidden sub-group exists"
@parent_group.add_member! @user
@sub_group.add_member! @user
end
Expand All @@ -112,7 +112,7 @@
@parent_group = FactoryGirl.create :group
@admin_user = FactoryGirl.create :user
@parent_group.add_admin! @admin_user
@sub_group = FactoryGirl.create :group, :parent => @parent_group, :privacy => 'secret', :viewable_by_parent_members => true
@sub_group = FactoryGirl.create :group, :parent => @parent_group, :privacy => 'hidden', :viewable_by_parent_members => true
@sub_group.add_admin! @admin_user
@parent_group.add_member! @user
end
Expand Down Expand Up @@ -167,7 +167,7 @@
@parent_group = FactoryGirl.create :group
@parent_group.add_member! @user
@sub_groups = []
['secret', 'public'].each do |privacy|
['hidden', 'public'].each do |privacy|
@sub_groups << FactoryGirl.create(:group,
parent: @parent_group,
privacy: privacy,
Expand All @@ -194,21 +194,21 @@
@group.privacy = 'public'
end

When(/^I set the group to secret$/) do
When(/^I set the group to hidden$/) do
visit edit_group_path(@group)
choose 'group_privacy_secret'
choose 'group_privacy_hidden'
click_on 'group_form_submit'
end

Then(/^the group should be set to secret$/) do
Then(/^the group should be set to hidden$/) do
@group.reload
@group.privacy.should == 'secret'
@group.privacy.should == 'hidden'
end

Given(/^I am a coordinator of a secret group$/) do
Given(/^I am a coordinator of a hidden group$/) do
@group = FactoryGirl.create :group
@group.add_admin! @user
@group.privacy = 'secret'
@group.privacy = 'hidden'
end

When(/^I set the group to public$/) do
Expand All @@ -223,7 +223,7 @@
@group.privacy = 'public'
end

Given(/^I am a coordinator of a secret subgroup$/) do
Given(/^I am a coordinator of a hidden subgroup$/) do
@parent_group = FactoryGirl.create :group
@parent_group.add_member! @user
@subgroup = FactoryGirl.create :group, parent: @parent_group
Expand Down

0 comments on commit cba33fe

Please sign in to comment.