Commit 1b8f082061e3f120ab02b263cb68e3433b028ef6
1 parent
68154e8f
Exists in
master
and in
4 other branches
new access rights implemented
Showing
11 changed files
with
65 additions
and
81 deletions
Show diff stats
app/controllers/projects_controller.rb
| ... | ... | @@ -30,7 +30,7 @@ class ProjectsController < ApplicationController |
| 30 | 30 | |
| 31 | 31 | Project.transaction do |
| 32 | 32 | @project.save! |
| 33 | - @project.users_projects.create!(:admin => true, :read => true, :write => true, :user => current_user) | |
| 33 | + @project.users_projects.create!(:repo_access => Repository::REPO_RW , :project_access => Project::PROJECT_RWA, :user => current_user) | |
| 34 | 34 | |
| 35 | 35 | # when project saved no team member exist so |
| 36 | 36 | # project repository should be updated after first user add | ... | ... |
app/views/admin/projects/show.html.haml
| ... | ... | @@ -43,18 +43,17 @@ |
| 43 | 43 | %tr |
| 44 | 44 | %th Name |
| 45 | 45 | %th Added |
| 46 | - %th Web | |
| 47 | - %th Git | |
| 48 | - %th Admin | |
| 46 | + %th Project Access | |
| 47 | + %th Repository Access | |
| 49 | 48 | %th |
| 50 | 49 | |
| 51 | 50 | - @admin_project.users_projects.each do |tm| |
| 52 | 51 | %tr |
| 53 | - %td= link_to tm.user_name, admin_team_member_path(tm) | |
| 52 | + %td | |
| 53 | + = link_to tm.user_name, admin_team_member_path(tm) | |
| 54 | 54 | %td= time_ago_in_words(tm.updated_at) + " ago" |
| 55 | - %td= check_box_tag "read", 1, @admin_project.readers.include?(tm.user), :disabled => :disabled | |
| 56 | - %td= check_box_tag "commit", 1, @admin_project.writers.include?(tm.user), :disabled => :disabled | |
| 57 | - %td.span-2= check_box_tag "admin", 1, @admin_project.admins.include?(tm.user), :disabled => :disabled | |
| 55 | + %td= select_tag :project_access, options_for_select(Project.access_options, tm.project_access), :class => "project-access-select", :disabled => :disabled | |
| 56 | + %td= select_tag :repo_access, options_for_select(Repository.access_options, tm.repo_access), :class => "repo-access-select", :disabled => :disabled | |
| 58 | 57 | %td= link_to 'Destroy', admin_team_member_path(tm), :confirm => 'Are you sure?', :method => :delete |
| 59 | 58 | |
| 60 | 59 | = link_to 'New Team Member', new_admin_team_member_path(:team_member => {:project_id => @admin_project.id}), :class => "grey-button" | ... | ... |
app/views/admin/team_members/_form.html.haml
| ... | ... | @@ -17,21 +17,26 @@ |
| 17 | 17 | = f.select :project_id, Project.all.map { |user| [user.name, user.id] } |
| 18 | 18 | |
| 19 | 19 | .span-6 |
| 20 | - %b Access: | |
| 20 | + %b Project Access: | |
| 21 | 21 | .span-6 |
| 22 | - = f.check_box :read | |
| 23 | - Web Access (Browse Repo) | |
| 22 | + = f.select :project_access, options_for_select(Project.access_options, @admin_team_member.project_access), {}, :class => "project-access-select" | |
| 23 | + | |
| 24 | 24 | .span-6 |
| 25 | - = f.check_box :write | |
| 26 | - Git Access (User will be added to commiters list) | |
| 25 | + %b Repository Access: | |
| 27 | 26 | .span-6 |
| 28 | - = f.check_box :admin | |
| 29 | - Admin (Can manage project) | |
| 27 | + = f.select :repo_access, options_for_select(Repository.access_options, @admin_team_member.repo_access), {}, :class => "repo-access-select" | |
| 30 | 28 | %br |
| 31 | 29 | .actions |
| 32 | 30 | = f.submit 'Save', :class => "grey-button" |
| 33 | 31 | |
| 32 | +:css | |
| 33 | + form select { | |
| 34 | + width:300px; | |
| 35 | + } | |
| 36 | + | |
| 34 | 37 | :javascript |
| 35 | - $('select#team_member_user_id').selectmenu({width:300}); | |
| 36 | - $('select#team_member_project_id').selectmenu({width:300}); | |
| 38 | + $('select#team_member_user_id').chosen(); | |
| 39 | + $('select#team_member_project_id').chosen(); | |
| 40 | + $('select#team_member_repo_access').chosen(); | |
| 41 | + $('select#team_member_project_access').chosen(); | |
| 37 | 42 | ... | ... |
app/views/admin/team_members/index.html.haml
| ... | ... | @@ -3,21 +3,21 @@ |
| 3 | 3 | %table |
| 4 | 4 | %thead |
| 5 | 5 | %th Name |
| 6 | - %th Email | |
| 7 | - %th Read | |
| 8 | - %th Git | |
| 9 | - %th Manage | |
| 6 | + %th Project Access | |
| 7 | + %th Repo Access | |
| 10 | 8 | %th Added |
| 11 | 9 | %th |
| 12 | 10 | %th |
| 13 | 11 | - members.each do |tm| |
| 14 | 12 | - user = tm.user |
| 15 | 13 | %tr |
| 16 | - %td.span-6= link_to tm.user_name, admin_team_member_path(tm) | |
| 17 | - %td.span-6= tm.user_email | |
| 18 | - %td.span-1= check_box_tag "read", 1, project.readers.include?(user), :disabled => :disabled | |
| 19 | - %td.span-1= check_box_tag "commit", 1, project.writers.include?(user), :disabled => :disabled | |
| 20 | - %td.span-2= check_box_tag "admin", 1, project.admins.include?(user), :disabled => :disabled | |
| 14 | + %td.span-6 | |
| 15 | + = link_to tm.user_name, admin_team_member_path(tm) | |
| 16 | + %br | |
| 17 | + %br | |
| 18 | + = tm.user_email | |
| 19 | + %td.span-3= select_tag :project_access, options_for_select(Project.access_options, tm.project_access), :class => "project-access-select", :disabled => :disabled | |
| 20 | + %td.span-3= select_tag :repo_access, options_for_select(Repository.access_options, tm.repo_access), :class => "repo-access-select", :disabled => :disabled | |
| 21 | 21 | %td.span-3= time_ago_in_words(tm.updated_at) + " ago" |
| 22 | 22 | %td= link_to 'Edit', edit_admin_team_member_path(tm), :id => "edit_#{dom_id(tm)}" |
| 23 | 23 | %td= link_to 'Destroy', admin_team_member_path(tm), :confirm => 'Are you sure?', :method => :delete | ... | ... |
app/views/admin/team_members/show.html.haml
| ... | ... | @@ -11,19 +11,13 @@ |
| 11 | 11 | |
| 12 | 12 | #infoblock |
| 13 | 13 | .span-6 |
| 14 | - %b Access: | |
| 15 | - %br | |
| 16 | - .span-6 | |
| 17 | - = check_box_tag "read", 1, @admin_team_member.read, :disabled => :disabled | |
| 18 | - Web Access (Browse Repo) | |
| 14 | + %b Project Access: | |
| 15 | + = select_tag :project_access, options_for_select(Project.access_options, @admin_team_member.project_access), :class => "project-access-select", :disabled => true | |
| 16 | + | |
| 19 | 17 | %br |
| 20 | 18 | .span-6 |
| 21 | - = check_box_tag "commit", 1, @admin_team_member.write, :disabled => :disabled | |
| 22 | - Git Access (User will be added to commiters list) | |
| 23 | - %br | |
| 24 | - .span-6.append-bottom | |
| 25 | - = check_box_tag "admin", 1, @admin_team_member.admin, :disabled => :disabled | |
| 26 | - Admin (Can manage project) | |
| 19 | + %b Repository Access: | |
| 20 | + = select_tag :repo_access, options_for_select(Repository.access_options, @admin_team_member.repo_access), :class => "repo-access-select", :disabled => true | |
| 27 | 21 | |
| 28 | 22 | %br |
| 29 | 23 | ... | ... |
app/views/admin/users/show.html.haml
| ... | ... | @@ -51,9 +51,8 @@ |
| 51 | 51 | %thead |
| 52 | 52 | %th Name |
| 53 | 53 | %th Added |
| 54 | - %th Web | |
| 55 | - %th Git | |
| 56 | - %th Admin | |
| 54 | + %th Project Access | |
| 55 | + %th Repository Access | |
| 57 | 56 | %th |
| 58 | 57 | %th |
| 59 | 58 | |
| ... | ... | @@ -62,9 +61,8 @@ |
| 62 | 61 | %tr |
| 63 | 62 | %td= link_to project.name, admin_project_path(project) |
| 64 | 63 | %td= time_ago_in_words(tm.updated_at) + " ago" |
| 65 | - %td= check_box_tag "read", 1, project.readers.include?(@admin_user), :disabled => :disabled | |
| 66 | - %td= check_box_tag "commit", 1, project.writers.include?(@admin_usertm), :disabled => :disabled | |
| 67 | - %td.span-2= check_box_tag "admin", 1, project.admins.include?(@admin_user), :disabled => :disabled | |
| 64 | + %td= select_tag :project_access, options_for_select(Project.access_options, tm.project_access), :class => "project-access-select", :disabled => :disabled | |
| 65 | + %td= select_tag :repo_access, options_for_select(Repository.access_options, tm.repo_access), :class => "repo-access-select", :disabled => :disabled | |
| 68 | 66 | %td= link_to 'Edit', edit_admin_team_member_path(tm) |
| 69 | 67 | %td= link_to 'Cancel', admin_team_member_path(tm), :confirm => 'Are you sure?', :method => :delete |
| 70 | 68 | ... | ... |
app/views/projects/_team.html.haml
| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | |
| 15 | 15 | :javascript |
| 16 | 16 | $(function(){ |
| 17 | - $('.repo-access-select, .project-access-select').live("change", function() { | |
| 17 | + $('#team-table .repo-access-select, #team-table .project-access-select').live("change", function() { | |
| 18 | 18 | $(this.form).submit(); |
| 19 | 19 | }); |
| 20 | 20 | }) | ... | ... |
app/views/team_members/_form.html.haml
| ... | ... | @@ -10,16 +10,15 @@ |
| 10 | 10 | .span-6 |
| 11 | 11 | = f.select(:user_id, User.not_in_project(@project).all.collect {|p| [ p.name, p.id ] }, { :include_blank => "Select user" }, { :style => "width:300px" }) |
| 12 | 12 | .span-6 |
| 13 | - %b Access: | |
| 13 | + %b Project Access: | |
| 14 | 14 | .span-6 |
| 15 | - = f.check_box :read | |
| 16 | - Web Access | |
| 15 | + = f.select :project_access, options_for_select(Project.access_options, @team_member.project_access), {}, :class => "project-access-select" | |
| 16 | + | |
| 17 | 17 | .span-6 |
| 18 | - = f.check_box :write | |
| 19 | - Git Access | |
| 20 | - .span-6.append-bottom | |
| 21 | - = f.check_box :admin | |
| 22 | - Admin | |
| 18 | + %b Repository Access: | |
| 19 | + .span-6 | |
| 20 | + = f.select :repo_access, options_for_select(Repository.access_options, @team_member.repo_access), {}, :class => "repo-access-select" | |
| 23 | 21 | %br |
| 24 | 22 | .span-6 |
| 25 | 23 | = f.submit 'Save', :class => "grey-button" |
| 24 | + | ... | ... |
app/views/team_members/new.js.haml
spec/models/note_spec.rb
| ... | ... | @@ -31,9 +31,9 @@ describe Note do |
| 31 | 31 | |
| 32 | 32 | describe :read do |
| 33 | 33 | before do |
| 34 | - @p1.users_projects.create(:user => @u1, :read => false) | |
| 35 | - @p1.users_projects.create(:user => @u2, :read => true) | |
| 36 | - @p2.users_projects.create(:user => @u3, :read => true) | |
| 34 | + @p1.users_projects.create(:user => @u1, :project_access => Project::PROJECT_N) | |
| 35 | + @p1.users_projects.create(:user => @u2, :project_access => Project::PROJECT_R) | |
| 36 | + @p2.users_projects.create(:user => @u3, :project_access => Project::PROJECT_R) | |
| 37 | 37 | end |
| 38 | 38 | |
| 39 | 39 | it { @abilities.allowed?(@u1, :read_note, @p1).should be_false } |
| ... | ... | @@ -43,9 +43,9 @@ describe Note do |
| 43 | 43 | |
| 44 | 44 | describe :write do |
| 45 | 45 | before do |
| 46 | - @p1.users_projects.create(:user => @u1, :write => false) | |
| 47 | - @p1.users_projects.create(:user => @u2, :write => true) | |
| 48 | - @p2.users_projects.create(:user => @u3, :write => true) | |
| 46 | + @p1.users_projects.create(:user => @u1, :project_access => Project::PROJECT_R) | |
| 47 | + @p1.users_projects.create(:user => @u2, :project_access => Project::PROJECT_RW) | |
| 48 | + @p2.users_projects.create(:user => @u3, :project_access => Project::PROJECT_RW) | |
| 49 | 49 | end |
| 50 | 50 | |
| 51 | 51 | it { @abilities.allowed?(@u1, :write_note, @p1).should be_false } |
| ... | ... | @@ -55,9 +55,9 @@ describe Note do |
| 55 | 55 | |
| 56 | 56 | describe :admin do |
| 57 | 57 | before do |
| 58 | - @p1.users_projects.create(:user => @u1, :admin => false) | |
| 59 | - @p1.users_projects.create(:user => @u2, :admin => true) | |
| 60 | - @p2.users_projects.create(:user => @u3, :admin => true) | |
| 58 | + @p1.users_projects.create(:user => @u1, :project_access => Project::PROJECT_R) | |
| 59 | + @p1.users_projects.create(:user => @u2, :project_access => Project::PROJECT_RWA) | |
| 60 | + @p2.users_projects.create(:user => @u3, :project_access => Project::PROJECT_RWA) | |
| 61 | 61 | end |
| 62 | 62 | |
| 63 | 63 | it { @abilities.allowed?(@u1, :admin_note, @p1).should be_false } | ... | ... |
spec/requests/team_members_spec.rb
| ... | ... | @@ -32,11 +32,10 @@ describe "TeamMembers" do |
| 32 | 32 | describe "fill in" do |
| 33 | 33 | before do |
| 34 | 34 | page.execute_script("$('#team_member_user_id').show();") |
| 35 | - select @user_1.name, :from => "team_member_user_id" | |
| 36 | - | |
| 37 | - within "#team_member_new" do | |
| 38 | - check "team_member_read" | |
| 39 | - check "team_member_write" | |
| 35 | + within "#team_member_new" do | |
| 36 | + select @user_1.name, :from => "team_member_user_id" | |
| 37 | + select "Report", :from => "team_member_project_access" | |
| 38 | + select "Pull", :from => "team_member_repo_access" | |
| 40 | 39 | end |
| 41 | 40 | end |
| 42 | 41 | |
| ... | ... | @@ -48,20 +47,9 @@ describe "TeamMembers" do |
| 48 | 47 | |
| 49 | 48 | page.should have_content @user_1.name |
| 50 | 49 | |
| 51 | - @member.read.should be_true | |
| 52 | - @member.write.should be_true | |
| 53 | - @member.admin.should be_false | |
| 54 | - end | |
| 55 | - | |
| 56 | - it "should not allow creation without access selected" do | |
| 57 | - within "#team_member_new" do | |
| 58 | - uncheck "team_member_read" | |
| 59 | - uncheck "team_member_write" | |
| 60 | - uncheck "team_member_admin" | |
| 61 | - end | |
| 62 | - | |
| 63 | - expect { click_button "Save" }.to_not change {UsersProject.count} | |
| 64 | - page.should have_content("Please choose at least one Role in the Access list") | |
| 50 | + @member.reload | |
| 51 | + @member.project_access.should == Project::PROJECT_RW | |
| 52 | + @member.repo_access.should == Repository::REPO_R | |
| 65 | 53 | end |
| 66 | 54 | end |
| 67 | 55 | end | ... | ... |