Merge pull request #277 from opf/feature/rails3_activity_module
Feature/rails3 activity modulepull/168/merge
commit
82ce771bb5
@ -0,0 +1,21 @@ |
|||||||
|
class AddActivityModule < ActiveRecord::Migration |
||||||
|
def up |
||||||
|
# activate activity module for all projects |
||||||
|
Project.all.each do |project| |
||||||
|
project.enabled_module_names = ["activity"] | project.enabled_module_names |
||||||
|
end |
||||||
|
|
||||||
|
# add activity module from default settings |
||||||
|
Setting["default_projects_modules"] = ["activity"] | Setting.default_projects_modules |
||||||
|
end |
||||||
|
|
||||||
|
def down |
||||||
|
# deactivate activity module for all projects |
||||||
|
Project.all.each do |project| |
||||||
|
project.enabled_module_names = project.enabled_module_names - ["activity"] |
||||||
|
end |
||||||
|
|
||||||
|
# remove activity module from default settings |
||||||
|
Setting["default_projects_modules"] = Setting.default_projects_modules - ["activity"] |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,36 @@ |
|||||||
|
#-- copyright |
||||||
|
# OpenProject is a project management system. |
||||||
|
# |
||||||
|
# Copyright (C) 2012-2013 the OpenProject Team |
||||||
|
# |
||||||
|
# This program is free software; you can redistribute it and/or |
||||||
|
# modify it under the terms of the GNU General Public License version 3. |
||||||
|
# |
||||||
|
# See doc/COPYRIGHT.rdoc for more details. |
||||||
|
#++ |
||||||
|
|
||||||
|
Feature: Activities |
||||||
|
|
||||||
|
Background: |
||||||
|
Given there is 1 project with the following: |
||||||
|
| Name | project1 | |
||||||
|
And the project "project1" has the following trackers: |
||||||
|
| name | position | |
||||||
|
| Bug | 1 | |
||||||
|
And the project "project1" has 1 issue with the following: |
||||||
|
| subject | issue1 | |
||||||
|
And there is 1 project with the following: |
||||||
|
| Name | project2 | |
||||||
|
And the project "project2" has the following trackers: |
||||||
|
| name | position | |
||||||
|
| Bug | 1 | |
||||||
|
And the project "project2" does not use the following modules: |
||||||
|
| activity | |
||||||
|
And the project "project2" has 1 issue with the following: |
||||||
|
| subject | issue2 | |
||||||
|
And I am already logged in as "admin" |
||||||
|
|
||||||
|
Scenario: Hide activity from Projects with disabled activity module |
||||||
|
When I go to the overall activity page |
||||||
|
Then I should see "project1" within "#activity" |
||||||
|
And I should not see "project2" within "#activity" |
@ -0,0 +1,51 @@ |
|||||||
|
#-- copyright |
||||||
|
# OpenProject is a project management system. |
||||||
|
# |
||||||
|
# Copyright (C) 2012-2013 the OpenProject Team |
||||||
|
# |
||||||
|
# This program is free software; you can redistribute it and/or |
||||||
|
# modify it under the terms of the GNU General Public License version 3. |
||||||
|
# |
||||||
|
# See doc/COPYRIGHT.rdoc for more details. |
||||||
|
#++ |
||||||
|
|
||||||
|
require 'spec_helper' |
||||||
|
|
||||||
|
describe ActivitiesController do |
||||||
|
before :each do |
||||||
|
@controller.stub(:set_localization) |
||||||
|
|
||||||
|
admin = FactoryGirl.create(:admin) |
||||||
|
User.stub(:current).and_return admin |
||||||
|
|
||||||
|
@params = {} |
||||||
|
end |
||||||
|
|
||||||
|
describe 'index' do |
||||||
|
describe 'with activated activity module' do |
||||||
|
before do |
||||||
|
@project = FactoryGirl.create(:project, :enabled_module_names => %w[activity wiki]) |
||||||
|
@params[:project_id] = @project.id |
||||||
|
end |
||||||
|
|
||||||
|
it 'renders activity' do |
||||||
|
get 'index', @params |
||||||
|
response.should be_success |
||||||
|
response.should render_template 'index' |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
describe 'without activated activity module' do |
||||||
|
before do |
||||||
|
@project = FactoryGirl.create(:project, :enabled_module_names => %w[wiki]) |
||||||
|
@params[:project_id] = @project.id |
||||||
|
end |
||||||
|
|
||||||
|
it 'renders 403' do |
||||||
|
get 'index', @params |
||||||
|
response.status.should == 403 |
||||||
|
response.should render_template 'common/error' |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,106 @@ |
|||||||
|
#-- copyright |
||||||
|
# OpenProject is a project management system. |
||||||
|
# |
||||||
|
# Copyright (C) 2012-2013 the OpenProject Team |
||||||
|
# |
||||||
|
# This program is free software; you can redistribute it and/or |
||||||
|
# modify it under the terms of the GNU General Public License version 3. |
||||||
|
# |
||||||
|
# See doc/COPYRIGHT.rdoc for more details. |
||||||
|
#++ |
||||||
|
|
||||||
|
require 'spec_helper' |
||||||
|
|
||||||
|
describe SettingsController do |
||||||
|
before :each do |
||||||
|
@controller.stub(:set_localization) |
||||||
|
@params = {} |
||||||
|
|
||||||
|
@user = FactoryGirl.create(:admin) |
||||||
|
User.stub(:current).and_return @user |
||||||
|
end |
||||||
|
|
||||||
|
describe 'edit' do |
||||||
|
render_views |
||||||
|
|
||||||
|
def clear_settings_cache |
||||||
|
Rails.cache.clear |
||||||
|
end |
||||||
|
|
||||||
|
# this is the base method for get, post, etc. |
||||||
|
def process(*args) |
||||||
|
clear_settings_cache |
||||||
|
result = super |
||||||
|
clear_settings_cache |
||||||
|
result |
||||||
|
end |
||||||
|
|
||||||
|
before(:all) do |
||||||
|
@previous_projects_modules = Setting.default_projects_modules |
||||||
|
end |
||||||
|
|
||||||
|
after(:all) do |
||||||
|
Setting.default_projects_modules = @previous_projects_modules |
||||||
|
end |
||||||
|
|
||||||
|
it 'contains a check box for the activity module on the projects tab' do |
||||||
|
get 'edit', :tab => 'projects' |
||||||
|
|
||||||
|
response.should be_success |
||||||
|
response.should render_template 'edit' |
||||||
|
response.body.should have_selector "input[@name='settings[default_projects_modules][]'][@value='activity']" |
||||||
|
end |
||||||
|
|
||||||
|
it 'does not store the activity in the default_projects_modules if unchecked' do |
||||||
|
post 'edit', :tab => 'projects', :settings => { |
||||||
|
:default_projects_modules => ['wiki'] |
||||||
|
} |
||||||
|
|
||||||
|
response.should be_redirect |
||||||
|
response.should redirect_to :action => 'edit', :tab => 'projects' |
||||||
|
|
||||||
|
Setting.default_projects_modules.should == ['wiki'] |
||||||
|
end |
||||||
|
|
||||||
|
it 'stores the activity in the default_projects_modules if checked' do |
||||||
|
post 'edit', :tab => 'projects', :settings => { |
||||||
|
:default_projects_modules => ['activity', 'wiki'] |
||||||
|
} |
||||||
|
|
||||||
|
response.should be_redirect |
||||||
|
response.should redirect_to :action => 'edit', :tab => 'projects' |
||||||
|
|
||||||
|
Setting.default_projects_modules.should == ['activity', 'wiki'] |
||||||
|
end |
||||||
|
|
||||||
|
describe 'with activity in Setting.default_projects_modules' do |
||||||
|
before do |
||||||
|
Setting.default_projects_modules = %w[activity wiki] |
||||||
|
end |
||||||
|
|
||||||
|
it 'contains a checked checkbox for activity' do |
||||||
|
get 'edit', :tab => 'projects' |
||||||
|
|
||||||
|
response.should be_success |
||||||
|
response.should render_template 'edit' |
||||||
|
|
||||||
|
response.body.should have_selector "input[@name='settings[default_projects_modules][]'][@value='activity'][@checked='checked']" |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
describe 'without activated activity module' do |
||||||
|
before do |
||||||
|
Setting.default_projects_modules = %w[wiki] |
||||||
|
end |
||||||
|
|
||||||
|
it 'contains an unchecked checkbox for activity' do |
||||||
|
get 'edit', :tab => 'projects' |
||||||
|
|
||||||
|
response.should be_success |
||||||
|
response.should render_template 'edit' |
||||||
|
|
||||||
|
response.body.should_not have_selector "input[@name='settings[default_projects_modules][]'][@value='activity'][@checked='checked']" |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
end |
Loading…
Reference in new issue