-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed #1 Test code and Improvements by testing
- Loading branch information
1 parent
d9742bf
commit e4532f8
Showing
18 changed files
with
387 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
source 'https://rubygems.org' | ||
|
||
group :test do | ||
gem 'factory_girl' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FactoryGirl.define do | ||
factory :default_query, class: ProjectsDefaultQuery do | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FactoryGirl.define do | ||
factory :enabled_module do | ||
factory :default_custom_query_module do | ||
name 'default_custom_query' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
FactoryGirl.define do | ||
factory :issue_query do | ||
sequence(:name) {|n| "IssueQuery#{n}"} | ||
|
||
user_id { User.current.id } | ||
|
||
if ::Redmine::VERSION.to_s < '2.4' | ||
trait :private do | ||
is_public false | ||
end | ||
|
||
trait :public do | ||
is_public true | ||
end | ||
else | ||
trait :private do | ||
visibility ::Query::VISIBILITY_PRIVATE | ||
end | ||
|
||
trait :roles do | ||
visibility ::Query::VISIBILITY_ROLES | ||
|
||
before(:create) do |query| | ||
query.roles << create(:role) | ||
end | ||
end | ||
|
||
trait :public do | ||
visibility ::Query::VISIBILITY_PUBLIC | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FactoryGirl.define do | ||
factory :member do | ||
mail_notification 0 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FactoryGirl.define do | ||
factory :project do | ||
sequence(:name) {|n| "Project#{n}"} | ||
sequence(:identifier) {|n| "project-#{n}"} | ||
end | ||
|
||
trait :with_default_custom_query do | ||
after(:create) do |project| | ||
create :default_custom_query_module, project: project | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
FactoryGirl.define do | ||
factory :role, aliases: [:role_with_manage_default_query] do | ||
sequence(:name) {|n| "Role#{n}"} | ||
sequence(:position) | ||
assignable 1 | ||
builtin 0 | ||
issues_visibility 'all' | ||
permissions { | ||
perms = Redmine::AccessControl.permissions - | ||
Redmine::AccessControl.public_permissions | ||
perms.map &:name | ||
} | ||
|
||
factory :role_without_manage_default_query do | ||
permissions { | ||
perms = Redmine::AccessControl.permissions - | ||
Redmine::AccessControl.public_permissions | ||
perms.map(&:name) - [:manage_default_query] | ||
} | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FactoryGirl.define do | ||
factory :user do | ||
sequence(:login, '000') {|n| "user#{n}"} | ||
sequence(:lastname, '0000') | ||
|
||
firstname 'User' | ||
status 1 | ||
language 'ja' | ||
mail {|u| "#{u.login}@example.co.jp" } | ||
mail_notification 'only_my_events' | ||
password '12345678' | ||
password_confirmation {|u| u.password } | ||
admin false | ||
type 'User' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
require File.expand_path('../../test_helper', __FILE__) | ||
|
||
class IssuesWithDefaultQueryTest < ActionController::IntegrationTest | ||
setup do | ||
setup_proper_project | ||
logged_in @user | ||
|
||
@default_query, @query = create_list(:issue_query, 2, :public, project: @project) | ||
end | ||
|
||
context 'when the default query is not set' do | ||
should 'not execute the script that render the button for showing default issues' do | ||
get project_issues_path(@project) | ||
|
||
assert_response :success | ||
assert_select 'script#add-default-issues-button', false | ||
end | ||
|
||
should 'not apply the default query' do | ||
get project_issues_path(@project) | ||
|
||
assert_response :success | ||
assert_show_all_issues | ||
end | ||
end | ||
|
||
context 'when the default query is set' do | ||
setup do | ||
set_default_query @project, @default_query | ||
end | ||
|
||
should 'execute the script that render the button for showing default issues' do | ||
get project_issues_path(@project) | ||
|
||
assert_response :success | ||
assert_select 'script#add-default-issues-button' | ||
end | ||
|
||
should 'be able to operate in issues with default query' do | ||
get project_issues_path(@project) | ||
|
||
# should apply the default query | ||
assert_response :success | ||
assert_apply_query @default_query | ||
|
||
# click the "View all issues" button | ||
get project_issues_path(@project, set_filter: 1, without_default: 1) | ||
|
||
assert_response :success | ||
assert_show_all_issues | ||
|
||
# select the other query | ||
get project_issues_path(@project, query_id: @query.id) | ||
|
||
assert_response :success | ||
assert_apply_query @query | ||
end | ||
|
||
context 'when deleted the query that has been set as default' do | ||
should 'unset the default query' do | ||
delete query_path(@default_query) | ||
|
||
assert_nil @project.default_query | ||
assert_response :redirect | ||
end | ||
end | ||
|
||
context 'when changed to PRIVATE the visilibity of the default query' do | ||
should 'unset the default query' do | ||
if Redmine::VERSION.to_s < '2.4' | ||
@default_query.update_attribute :is_public, false | ||
else | ||
@default_query.update_attribute :visibility, Query::VISIBILITY_PRIVATE | ||
end | ||
|
||
get project_issues_path(@project) | ||
|
||
assert_response :success | ||
assert_nil @project.default_query | ||
end | ||
end | ||
|
||
context 'when changed to ROLES the visibility of the default query' do | ||
should 'unset the default query' do | ||
if Redmine::VERSION.to_s < '2.4' | ||
omit '2.3 or less has no ROLES visility' | ||
else | ||
@default_query.visibility = Query::VISIBILITY_ROLES | ||
@default_query.roles << create(:role) | ||
@default_query.save! | ||
|
||
get project_issues_path(@project) | ||
|
||
assert_response :success | ||
assert_nil @project.default_query | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.